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) {
unset($preferences[$key]);
};
global $chestExercises;
global $backExercises;
global $legsExercises;
global $lowerLegsExercises;
global $bicepsExercises;
global $tricepsExercises;
global $shouldersExercises;
global $forearmsExercises;
global $absExercises;
$chestExercises = [];
$backExercises = [];
$legsExercises = [];
@ -62,7 +71,6 @@ class GeneratorController extends Controller
$shouldersExercises = [];
$forearmsExercises = [];
$absExercises = [];
#$Exercises = [];
function getExercises($muscle, $preference) {
$exercises = DB::table('exercises')
->where('exercise_type', $preference)
@ -82,9 +90,28 @@ class GeneratorController extends Controller
$absExercises = array_merge($absExercises, getExercises('abs', $preference));
};
};
$cardio = DB::table('exercises')
global $cardioExercises;
$cardioExercises = DB::table('exercises')
->where('exercise_type', 'cardio')
->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'));
$months = intval(Request::get('months'));
$frequency = intval(Request::get('frequency'));
@ -92,68 +119,62 @@ class GeneratorController extends Controller
switch ($total) {
case ($total >= 24):
$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;
case ($total > 6):
$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;
default:
global $days;
$days = [];
$experience = "Beginner";
$largeMuscleExercises = 1;
$smallMuscleExercises = 1;
$headers = ["Full Body Day"];
};
function fullBodyDay () {
};
function upperBodyDay () {
};
function lowerBodyDay () {
};
function chestDay ($frequency, $largeMuscleExercises, $smallMuscleExercises) {
};
function backDay () {
};
function legDay () {
};
function armDay () {
};
function createWorkout () {
for ($i = 0; $i < $frequency; $i++) {
if ($i % 2 == 0) {
if (count($cardioExercises) > 0) {
$days[] = getDay("Cardio Day", ["cardio"], 4);
} else {
$days[] = getDay("Full Body", ["chest", "back", "legs"], 1, ["biceps", "triceps", "shoulders", "forearms", "lowerLegs", "abs"], 1);
}
} else {
$days[] = getDay("Full Body", ["chest", "back", "legs"], 1, ["biceps", "triceps", "shoulders", "forearms", "lowerLegs", "abs"], 1);
}
$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', [
'goal' => ucfirst($goal),
'preferences' => implode(', ', $preferences),
'experience' => $experience,
'frequency' => $frequency,
'listsOfExercises' => $listsOfExercises,
'headers' => $headers
'days' => $days,
'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>
<br style="clear:both;" />
<p style="text-align:center;">This part is still under development, but check back soon!</p>
@for ($i = 0; $i < $frequency; $i++)
@foreach ($days as $day)
<table class="workout">
<h2>{{ $headers[$i] }}</h2>
<h2>{{ $day['name'] }}</h2>
<th>Exercise</th>
<th>Sets:</th>
<th>Reps:</th>
@for ($i = 0; $i < count)
@foreach ($day['exercises'] as $exercise)
<tr>
<td>{{ $goal }}</td>
<td>{{ $preferences }}</td>
<td>{{ $experience }}</td>
<td>{{ $frequency }} days per week</td>
<td>{{ $exercise }}</td>
<td>{{ $sets }}</td>
<td>{{ $reps }}</td>
</tr>
@endforeach
</table>
@endfor
</div>
@endforeach
@endsection