Beginner and Intermediate workouts functioning.

This commit is contained in:
William Brawner 2015-10-18 16:37:44 -05:00
parent 901a3272e3
commit 27b7b815ee
3 changed files with 81 additions and 62 deletions

View file

@ -53,6 +53,15 @@ class GeneratorController extends Controller
foreach (array_keys($preferences, '') as $key) { foreach (array_keys($preferences, '') as $key) {
unset($preferences[$key]); unset($preferences[$key]);
}; };
global $chestExercises;
global $backExercises;
global $legsExercises;
global $lowerLegsExercises;
global $bicepsExercises;
global $tricepsExercises;
global $shouldersExercises;
global $forearmsExercises;
global $absExercises;
$chestExercises = []; $chestExercises = [];
$backExercises = []; $backExercises = [];
$legsExercises = []; $legsExercises = [];
@ -62,7 +71,6 @@ class GeneratorController extends Controller
$shouldersExercises = []; $shouldersExercises = [];
$forearmsExercises = []; $forearmsExercises = [];
$absExercises = []; $absExercises = [];
#$Exercises = [];
function getExercises($muscle, $preference) { function getExercises($muscle, $preference) {
$exercises = DB::table('exercises') $exercises = DB::table('exercises')
->where('exercise_type', $preference) ->where('exercise_type', $preference)
@ -82,9 +90,28 @@ class GeneratorController extends Controller
$absExercises = array_merge($absExercises, getExercises('abs', $preference)); $absExercises = array_merge($absExercises, getExercises('abs', $preference));
}; };
}; };
$cardio = DB::table('exercises') global $cardioExercises;
$cardioExercises = DB::table('exercises')
->where('exercise_type', 'cardio') ->where('exercise_type', 'cardio')
->lists('exercise_name'); ->lists('exercise_name');
function getExerciseLists($muscle, $numberOfExercises) {
global ${"$muscle" . "Exercises"};
$shuffled = ${"$muscle" . "Exercises"};
shuffle($shuffled);
return array_slice($shuffled, 0, $numberOfExercises);
};
function getDay($title, $largeMuscles, $largeMuscleExercises, $smallMuscles = [], $smallMuscleExercises = 0) {
$listOfExercises = [];
foreach ($largeMuscles as $largeMuscle) {
$listOfExercises = array_merge($listOfExercises, getExerciseLists($largeMuscle, $largeMuscleExercises));
};
foreach ($smallMuscles as $smallMuscle) {
$listOfExercises = array_merge($listOfExercises, getExerciseLists($smallMuscle, $smallMuscleExercises));
};
return ['name' => $title . ' Day',
'exercises' => $listOfExercises
];
};
$years = intval(Request::get('years')); $years = intval(Request::get('years'));
$months = intval(Request::get('months')); $months = intval(Request::get('months'));
$frequency = intval(Request::get('frequency')); $frequency = intval(Request::get('frequency'));
@ -92,68 +119,62 @@ class GeneratorController extends Controller
switch ($total) { switch ($total) {
case ($total >= 24): case ($total >= 24):
$experience = "Advanced"; $experience = "Advanced";
global $days;
$days = [];
for ($i = 0; $i < $frequency; $i++) {
$days[] = getDay("Full Body", ["chest", "back", "legs"], 1, ["biceps", "triceps", "shoulders", "forearms", "lowerLegs", "abs"], 1);
};
break; break;
case ($total > 6): case ($total > 6):
$experience = "Intermediate"; $experience = "Intermediate";
global $days;
$days = [];
$workout = intval($frequency / 2);
$cardio = ($frequency % 2) * $workout;
if ($frequency == 1) {
$days[] = getDay("Cardio Day", ["cardio"], 4);
} else if ($frequency < 5) {
for ($i = 0; $i < $workout; $i++) {
$days[] = getDay("Upper Body Day", ["chest", "back"], 1, ["biceps", "triceps", "shoulders", "forearms"], 1);
$days[] = getDay("Lower Body Day", ["legs"], 2, ["lowerLegs", "abs"], 1);
}
for ($i = 0; $i < $cardio; $i++) {
$days[] = getDay("Cardio Day", ["cardio"], 4);
}
} else {
for ($i = 0; $i < 2; $i++) {
$days[] = getDay("Upper Body Day", ["chest", "back"], 1, ["biceps", "triceps", "shoulders", "forearms"], 1);
$days[] = getDay("Lower Body Day", ["legs"], 2, ["lowerLegs", "abs"], 1);
}
for ($i = 0; $i < ($frequency - 4); $i++) {
$days[] = getDay("Cardio Day", ["cardio"], 4);
}
}
break; break;
default: default:
global $days;
$days = [];
$experience = "Beginner"; $experience = "Beginner";
$largeMuscleExercises = 1; for ($i = 0; $i < $frequency; $i++) {
$smallMuscleExercises = 1; if ($i % 2 == 0) {
$headers = ["Full Body Day"]; if (count($cardioExercises) > 0) {
}; $days[] = getDay("Cardio Day", ["cardio"], 4);
function fullBodyDay () { } else {
$days[] = getDay("Full Body", ["chest", "back", "legs"], 1, ["biceps", "triceps", "shoulders", "forearms", "lowerLegs", "abs"], 1);
}; }
function upperBodyDay () { } else {
$days[] = getDay("Full Body", ["chest", "back", "legs"], 1, ["biceps", "triceps", "shoulders", "forearms", "lowerLegs", "abs"], 1);
}; }
function lowerBodyDay () { };
};
function chestDay ($frequency, $largeMuscleExercises, $smallMuscleExercises) {
};
function backDay () {
};
function legDay () {
};
function armDay () {
};
function createWorkout () {
}
$listsOfExercises = [
$chestExercises,
$backExercises,
$legsExercises,
$lowerLegsExercises,
$bicepsExercises,
$tricepsExercises,
$shouldersExercises,
$forearmsExercises,
$absExercises,
$cardio
];
for ($i = 0; $i < count($listsOfExercises); $i++) {
shuffle($listsOfExercises[$i]);
};
for ($i = 0; $i < 3; $i++) {
$listsOfExercises[$i] = array_slice($listsOfExercises[$i], 0, $largeMuscleExercises);
};
for ($i = 3; $i < count($listsOfExercises); $i++) {
$listsOfExercises[$i] = array_slice($listsOfExercises[$i], 0, $smallMuscleExercises);
}; };
return view('generator/workout', [ return view('generator/workout', [
'goal' => ucfirst($goal), 'goal' => ucfirst($goal),
'preferences' => implode(', ', $preferences), 'preferences' => implode(', ', $preferences),
'experience' => $experience, 'experience' => $experience,
'frequency' => $frequency, 'frequency' => $frequency,
'listsOfExercises' => $listsOfExercises, 'days' => $days,
'headers' => $headers 'sets' => $sets,
'reps' => $reps
]); ]);
} }
} }

BIN
latest.dump Normal file

Binary file not shown.

View file

@ -9,21 +9,19 @@
<h1>{{ $goal }} - {{ $experience }} - {{ $frequency }} Day Split</h1> <h1>{{ $goal }} - {{ $experience }} - {{ $frequency }} Day Split</h1>
<br style="clear:both;" /> <br style="clear:both;" />
<p style="text-align:center;">This part is still under development, but check back soon!</p> <p style="text-align:center;">This part is still under development, but check back soon!</p>
@foreach ($days as $day)
@for ($i = 0; $i < $frequency; $i++)
<table class="workout"> <table class="workout">
<h2>{{ $headers[$i] }}</h2> <h2>{{ $day['name'] }}</h2>
<th>Exercise</th> <th>Exercise</th>
<th>Sets:</th> <th>Sets:</th>
<th>Reps:</th> <th>Reps:</th>
@for ($i = 0; $i < count) @foreach ($day['exercises'] as $exercise)
<tr> <tr>
<td>{{ $goal }}</td> <td>{{ $exercise }}</td>
<td>{{ $preferences }}</td> <td>{{ $sets }}</td>
<td>{{ $experience }}</td> <td>{{ $reps }}</td>
<td>{{ $frequency }} days per week</td>
</tr> </tr>
@endforeach
</table> </table>
@endfor @endforeach
</div>
@endsection @endsection