From 27b7b815ee56d3fc38e8f11439465ab096272fde Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sun, 18 Oct 2015 16:37:44 -0500 Subject: [PATCH] Beginner and Intermediate workouts functioning. --- app/Http/Controllers/GeneratorController.php | 125 +++++++++++-------- latest.dump | Bin 0 -> 8358 bytes resources/views/generator/workout.blade.php | 18 ++- 3 files changed, 81 insertions(+), 62 deletions(-) create mode 100644 latest.dump diff --git a/app/Http/Controllers/GeneratorController.php b/app/Http/Controllers/GeneratorController.php index eaf7692..8cec9e0 100644 --- a/app/Http/Controllers/GeneratorController.php +++ b/app/Http/Controllers/GeneratorController.php @@ -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 () { - - } - $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); + 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); + } + }; }; return view('generator/workout', [ 'goal' => ucfirst($goal), 'preferences' => implode(', ', $preferences), 'experience' => $experience, 'frequency' => $frequency, - 'listsOfExercises' => $listsOfExercises, - 'headers' => $headers + 'days' => $days, + 'sets' => $sets, + 'reps' => $reps ]); } } \ No newline at end of file diff --git a/latest.dump b/latest.dump new file mode 100644 index 0000000000000000000000000000000000000000..5c8a9e35dafc547033766f771258705d531cd773 GIT binary patch literal 8358 zcmcIp3tUvi8ef!DP_C$6}w3Xw#f&gk~h4^4d-{wc*Opfi$$*{&hX zI*Xn(8$c?EQLCmV#Y_rCvlv)lcZ2(|Bn4Wdjlcu_sZQ8l^D78qq*RHNsw^mplHv7< zg<+y8P#BwCYu0P6dX3IvF0fclP#}%XZiPQKB$&l~Phz#Z#0rM%aN_y#4Ac|PW+$`b zxePy0Be+BYl^{)^6f>}d3t*2hODs@{fpY+Kw-3mcs4{>`EX$OlS*gHIn2L;AJHZA{ zGq}J7QlUnukkS)l2(w15jDxU`Pl~}qs@zP(q1ym72(pjSbZe zsEJVG2jLKw*lVB`d+#F~cU-+?{$Z!35%XQb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vm^8$KSie~1sBi~O#4_;|3sfA|D3aPis-0V{iR z%ZgdH^ZW-7uGy$KH(}qh$7apG{m^!@w7Q=Ba`lH-nwD*gI99vu9sOtK$>qymvYh-x zu+7pG-Fe~ix8mmGd9m#`zgQcweDAuICKfG?YtWo>Y}5E%S$qrj~YF&V*jRdvA;fZbi{aF9rx_P_T3pTHDxV&EvIHi{zJ_#$Qrqw<65g{ zAF*E@|MSeJ_Jiuy+M;{sc!S)jM zujfZUzJVV$VsFL5q4jZx$nS@Kn_IZ@<*2UG$X?;R*F8Ib1CAO;J|B9n^u3>FoOJh*NBDZQVokQ z%uaf>xhcA&BC9dM7=L=h460fAtfklIN+jf@`^k%F&lrO@CDW)2PyP z0mn$}`C;o+VeL(mVavv!HXb^2OfEk8D!85}OXI!za{%Gq>&DM|e9g-@+nNJ>QU!MI)OHF=6 zS@Pex(XaiI_u=BR@ywKuc$Z~^Z`{iK{l|{*?QNNwbKtmTCm4BI zaMi|~(w-REnpRz}?)cBSU)V=xS8Aut6-}R;Tq-=VY{~KZ!d1gYjf$%57d^jg0q6JV z)~Y9(aX1WO;KL58jmzFtHwi))u)~GT@26HZsT!`wrERW$0Wi4{se8t}xboI-OV*E9 ztsT}eWCLeZerffF@3q>EkIa+KHy*im@aYj%Uvvx}{`R78_sWiM>>Q9nUbu3*P_sBZ jj%9ixnqCT@OTzF{mCYB{{ $goal }} - {{ $experience }} - {{ $frequency }} Day Split

This part is still under development, but check back soon!

- - @for ($i = 0; $i < $frequency; $i++) + @foreach ($days as $day) -

{{ $headers[$i] }}

+

{{ $day['name'] }}

- @for ($i = 0; $i < count) + @foreach ($day['exercises'] as $exercise) - - - - + + + + @endforeach
Exercise Sets: Reps:
{{ $goal }}{{ $preferences }}{{ $experience }}{{ $frequency }} days per week{{ $exercise }}{{ $sets }}{{ $reps }}
- @endfor - + @endforeach @endsection \ No newline at end of file