More work on the generator, not quite finished but the exercises are getting pulled from the database according to the user's preferences at least.
This commit is contained in:
parent
299e3aa523
commit
7ead111a3b
8 changed files with 106 additions and 262 deletions
|
@ -24,23 +24,21 @@ class GeneratorController extends Controller
|
|||
{
|
||||
$input = Request::all();
|
||||
$goal = Request::get('goal');
|
||||
$sets = 0;
|
||||
$reps = "";
|
||||
switch ($goal) {
|
||||
case "strength":
|
||||
$sets = 8;
|
||||
$sets = "5-8";
|
||||
$reps = "1-6";
|
||||
break;
|
||||
case "endurance":
|
||||
$sets = 3;
|
||||
$sets = "3";
|
||||
$reps = "15-25";
|
||||
break;
|
||||
case "definition":
|
||||
$sets = 4;
|
||||
$sets = "4";
|
||||
$reps = "8-12";
|
||||
break;
|
||||
default:
|
||||
$sets = 3;
|
||||
$sets = "3";
|
||||
$reps = "10";
|
||||
};
|
||||
$preferences = [
|
||||
|
@ -55,16 +53,16 @@ class GeneratorController extends Controller
|
|||
foreach (array_keys($preferences, '') as $key) {
|
||||
unset($preferences[$key]);
|
||||
};
|
||||
$chest_exercises = [];
|
||||
$back_exercises = [];
|
||||
$legs_exercises = [];
|
||||
$lower_legs_exercises = [];
|
||||
$biceps_exercises = [];
|
||||
$triceps_exercises = [];
|
||||
$shoulders_exercises = [];
|
||||
$forearms_exercises = [];
|
||||
$abs_exercises = [];
|
||||
#$_exercises = [];
|
||||
$chestExercises = [];
|
||||
$backExercises = [];
|
||||
$legsExercises = [];
|
||||
$lowerLegsExercises = [];
|
||||
$bicepsExercises = [];
|
||||
$tricepsExercises = [];
|
||||
$shouldersExercises = [];
|
||||
$forearmsExercises = [];
|
||||
$absExercises = [];
|
||||
#$Exercises = [];
|
||||
function getExercises($muscle, $preference) {
|
||||
$exercises = DB::table('exercises')
|
||||
->where('exercise_type', $preference)
|
||||
|
@ -73,48 +71,89 @@ class GeneratorController extends Controller
|
|||
return $exercises;
|
||||
};
|
||||
foreach ($preferences as $preference) {
|
||||
$chest_exercises = array_merge($chest_exercises, getExercises('chest', $preference));
|
||||
$back_exercises = array_merge($back_exercises, getExercises('back', $preference));
|
||||
$legs_exercises = array_merge($legs_exercises, getExercises('legs', $preference));
|
||||
$lower_legs_exercises = array_merge($lower_legs_exercises, getExercises('lower_legs', $preference));
|
||||
$biceps_exercises = array_merge($biceps_exercises, getExercises('biceps', $preference));
|
||||
$triceps_exercises = array_merge($triceps_exercises, getExercises('triceps', $preference));
|
||||
$shoulders_exercises = array_merge($shoulders_exercises, getExercises('shoulders', $preference));
|
||||
$forearms_exercises = array_merge($forearms_exercises, getExercises('forearms', $preference));
|
||||
$abs_exercises = array_merge($abs_exercises, getExercises('abs', $preference));
|
||||
$chestExercises = array_merge($chestExercises, getExercises('chest', $preference));
|
||||
$backExercises = array_merge($backExercises, getExercises('back', $preference));
|
||||
$legsExercises = array_merge($legsExercises, getExercises('legs', $preference));
|
||||
$lowerLegsExercises = array_merge($lowerLegsExercises, getExercises('lowerLegs', $preference));
|
||||
$bicepsExercises = array_merge($bicepsExercises, getExercises('biceps', $preference));
|
||||
$tricepsExercises = array_merge($tricepsExercises, getExercises('triceps', $preference));
|
||||
$shouldersExercises = array_merge($shouldersExercises, getExercises('shoulders', $preference));
|
||||
$forearmsExercises = array_merge($forearmsExercises, getExercises('forearms', $preference));
|
||||
$absExercises = array_merge($absExercises, getExercises('abs', $preference));
|
||||
};
|
||||
};
|
||||
$cardio = DB::table('exercises')
|
||||
->where('exercise_type', 'cardio')
|
||||
->lists('exercise_name');
|
||||
$years = intval(Request::get('years'));
|
||||
$months = intval(Request::get('months'));
|
||||
$frequency = intval(Request::get('frequency'));
|
||||
$total = ($years * 12) + $months;
|
||||
$experience = 0;
|
||||
switch ($total) {
|
||||
case ($total >= 24):
|
||||
$experience = 3;
|
||||
$experience = "Advanced";
|
||||
break;
|
||||
case ($total > 6):
|
||||
$experience = 2;
|
||||
$experience = "Intermediate";
|
||||
break;
|
||||
default:
|
||||
$experience = 1;
|
||||
$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);
|
||||
};
|
||||
$frequency = intval(Request::get('frequency'));
|
||||
$large_muscle = 3;
|
||||
$small_muscle = 2;
|
||||
return view('generator/workout', [
|
||||
'goal' => $goal,
|
||||
'goal' => ucfirst($goal),
|
||||
'preferences' => implode(', ', $preferences),
|
||||
'experience' => $experience,
|
||||
'frequency' => $frequency,
|
||||
'chest_exercises' => array_slice($chest_exercises, 0, $large_muscle),
|
||||
'back_exercises' => array_slice($back_exercises, 0, $large_muscle),
|
||||
'legs_exercises' => array_slice($legs_exercises, 0, $large_muscle),
|
||||
'lower_legs_exercises' => array_slice($lower_legs_exercises, 0, $small_muscle),
|
||||
'biceps_exercises' => array_slice($biceps_exercises, 0, $small_muscle),
|
||||
'triceps_exercises' => array_slice($triceps_exercises, 0, $small_muscle),
|
||||
'shoulders_exercises' => array_slice($shoulders_exercises, 0, $small_muscle),
|
||||
'forearms_exercises' => array_slice($forearms_exercises, 0, $small_muscle),
|
||||
'abs_exercises' => array_slice($abs_exercises, 0, $small_muscle)
|
||||
'listsOfExercises' => $listsOfExercises,
|
||||
'headers' => $headers
|
||||
]);
|
||||
}
|
||||
}
|
0
exercises.dump
Normal file
0
exercises.dump
Normal file
2
public/assets/css/styles.css
vendored
2
public/assets/css/styles.css
vendored
|
@ -200,7 +200,7 @@ body {
|
|||
.workout {
|
||||
width:75%;
|
||||
border:1px solid black;
|
||||
margin:auto;
|
||||
margin:10px auto;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
@extends('layouts.master')
|
||||
|
||||
@section('title', 'Generate')
|
||||
|
||||
@section('content')
|
||||
<div class="content" style="padding-bottom:0;">
|
||||
<h1>Workout Generator</h1>
|
||||
<div class="generator">
|
||||
<div class="fs-div">
|
||||
<form method="post" action="/generate/workout">
|
||||
<fieldset>
|
||||
<input type="hidden" name="_token" value="{{ csrf_token() }}">
|
||||
<legend>Background Info:</legend>
|
||||
<label>What is your primary goal?:</label>
|
||||
<br />
|
||||
<br />
|
||||
<select name='goal'>
|
||||
<option value="strength">Gain Strength</option>
|
||||
<option value="endurance">Gain Endurance</option>
|
||||
<option value="definition">Gain Definition</option>
|
||||
</select>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<label>Which of the following equipment/exercise styles do you have access to and enjoy doing? Check all that apply:</label>
|
||||
<br />
|
||||
<br />
|
||||
<input type="checkbox" name="free_weights" id="free-weights" value="free_weights" onClick="control()">Free Weights
|
||||
<br />
|
||||
<input type="checkbox" name="dumbbells" id="dumbbells" value="dumbbells" disabled><span class="dtext">Dumbbells</span>
|
||||
<br />
|
||||
<input type="checkbox" name="barbells" id="barbells" value="barbells" disabled><span class="dtext">Barbells</span>
|
||||
<br />
|
||||
<input type="checkbox" name="selectorized" value="selectorized">Selectorized Equipment
|
||||
<br />
|
||||
<input type="checkbox" name="cable" value="cable">Cable Equipment
|
||||
<br />
|
||||
<input type="checkbox" name="calisthenics" value="calisthenics">Calisthenics
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<label>How long have you consistently followed an exercise routine?</label>
|
||||
<br />
|
||||
<br />
|
||||
<select name="years">
|
||||
<option value="0">0 years</option>
|
||||
<option value="1">1 year</option>
|
||||
<option value="2">2+ years</option>
|
||||
</select>
|
||||
<select name="months">
|
||||
<?php
|
||||
for ($i = 0; $i <= 11; $i++) {
|
||||
echo "<option value=\"{$i}\">{$i} months</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<label>How many days would you like to workout this week?</label>
|
||||
<br />
|
||||
<br />
|
||||
<select name="frequency">
|
||||
<?php
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
echo "<option value=\"{$i}\">{$i}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<br />
|
||||
<button name="submit" class="home-button">Generate My Workout!</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var fw = document.getElementById("free-weights");
|
||||
var db = document.getElementById("dumbbells");
|
||||
var bb = document.getElementById("barbells");
|
||||
var dtext = document.getElementsByClassName("dtext");
|
||||
for (var i = 0; i < dtext.length; i++) {
|
||||
dtext[i].style.color = "#CCCCCC";
|
||||
};
|
||||
function control () {
|
||||
if (fw.checked === true) {
|
||||
db.disabled = false;
|
||||
bb.disabled = false;
|
||||
for (var i = 0; i < dtext.length; i++) {
|
||||
dtext[i].style.color = "#000000";
|
||||
};
|
||||
} else {
|
||||
db.disabled = true;
|
||||
bb.disabled = true;
|
||||
for (var i = 0; i < dtext.length; i++) {
|
||||
dtext[i].style.color = "#CCCCCC";
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@endsection
|
|
@ -1,100 +0,0 @@
|
|||
@extends('layouts.master')
|
||||
|
||||
@section('title', 'Generate')
|
||||
|
||||
@section('header')
|
||||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
<h1>Workout Generator</h1>
|
||||
<form method="post">
|
||||
<fieldset>
|
||||
<legend>Background Info:</legend>
|
||||
<label>What is your primary goal?:</label>
|
||||
<br />
|
||||
<br />
|
||||
<select name='goal'>
|
||||
<option value="strength">Gain Strength</option>
|
||||
<option value="endurance">Gain Endurance</option>
|
||||
<option value="definition">Gain Definition</option>
|
||||
</select>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<label>Which of the following equipment/exercise styles do you have access to and enjoy doing? Check all that apply:</label>
|
||||
<br />
|
||||
<br />
|
||||
<input type="checkbox" id="free-weights" value="free-weights" onClick="control()">Free Weights
|
||||
<br />
|
||||
<input type="checkbox" id="dumbbells" value="dumbbells" disabled><span class="dtext">Dumbbells</span>
|
||||
<br />
|
||||
<input type="checkbox" id="barbells" value="barbells" disabled><span class="dtext">Barbells</span>
|
||||
<br />
|
||||
<input type="checkbox" value="selectorized">Selectorized Equipment
|
||||
<br />
|
||||
<input type="checkbox" value="cables">Cable Equipment
|
||||
<br />
|
||||
<input type="checkbox" value="calisthenics">Calisthenics
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<label>How long have you consistently followed an exercise routine?</label>
|
||||
<br />
|
||||
<br />
|
||||
<select>
|
||||
<option>0 years</option>
|
||||
<option>1 year</option>
|
||||
<option>2+ years</option>
|
||||
</select>
|
||||
<select>
|
||||
<?php
|
||||
for ($i = 0; $i <= 11; $i++) {
|
||||
echo '<option>' . $i . ' months</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<br />
|
||||
<br />
|
||||
<label>How many days would you like to workout this week?</label>
|
||||
<br />
|
||||
<br />
|
||||
<select>
|
||||
<?php
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
echo '<option>' . $i . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br />
|
||||
<br />
|
||||
<button name="">Generate My Workout!</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<br />
|
||||
</div>
|
||||
<script>
|
||||
var fw = document.getElementById("free-weights");
|
||||
var db = document.getElementById("dumbbells");
|
||||
var bb = document.getElementById("barbells");
|
||||
var dtext = document.getElementsByClassName("dtext");
|
||||
for (var i = 0; i < dtext.length; i++) {
|
||||
dtext[i].style.color = "#CCCCCC";
|
||||
};
|
||||
function control () {
|
||||
if (fw.checked === true) {
|
||||
db.disabled = false;
|
||||
bb.disabled = false;
|
||||
for (var i = 0; i < dtext.length; i++) {
|
||||
dtext[i].style.color = "#000000";
|
||||
};
|
||||
} else {
|
||||
db.disabled = true;
|
||||
bb.disabled = true;
|
||||
for (var i = 0; i < dtext.length; i++) {
|
||||
dtext[i].style.color = "#CCCCCC";
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@endsection
|
|
@ -14,7 +14,8 @@
|
|||
<label>What is your primary goal?:</label>
|
||||
<br />
|
||||
<br />
|
||||
<select name='goal'>
|
||||
<select name='goal' required>
|
||||
<option value="" disabled selected>Select Your Goal:</option>
|
||||
<option value="strength">Gain Strength</option>
|
||||
<option value="endurance">Gain Endurance</option>
|
||||
<option value="definition">Gain Definition</option>
|
||||
|
@ -42,15 +43,17 @@
|
|||
<label>How long have you consistently followed an exercise routine?</label>
|
||||
<br />
|
||||
<br />
|
||||
<select name="years">
|
||||
<option value="0">0 years</option>
|
||||
<option value="1">1 year</option>
|
||||
<option value="2">2+ years</option>
|
||||
<select name="years" required>
|
||||
<option value="" disabled selected>Years:</option>
|
||||
<option value="0">0</option>
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
</select>
|
||||
<select name="months">
|
||||
<select name="months" required>
|
||||
<option value="" disabled selected>Months:</option>
|
||||
<?php
|
||||
for ($i = 0; $i <= 11; $i++) {
|
||||
echo "<option value=\"{$i}\">{$i} months</option>";
|
||||
echo "<option value=\"{$i}\">{$i}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
@ -60,7 +63,8 @@
|
|||
<label>How many days would you like to workout this week?</label>
|
||||
<br />
|
||||
<br />
|
||||
<select name="frequency">
|
||||
<select name="frequency" required>
|
||||
<option value="" disabled selected>Days per Week:</option>
|
||||
<?php
|
||||
for ($i = 1; $i <= 6; $i++) {
|
||||
echo "<option value=\"{$i}\">{$i}</option>";
|
||||
|
|
|
@ -6,21 +6,24 @@
|
|||
|
||||
@section('content')
|
||||
<div class="content">
|
||||
<h1>Your Workout, Should You Choose to Accept It...</h1>
|
||||
<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>
|
||||
{{-- <table class="workout">
|
||||
<th>Your Goal:</th>
|
||||
<th>Your Preferred Workout Types:</th>
|
||||
<th>Your Experience:</th>
|
||||
<th>Your Desired Workout Frequency:</th>
|
||||
|
||||
@for ($i = 0; $i < $frequency; $i++)
|
||||
<table class="workout">
|
||||
<h2>{{ $headers[$i] }}</h2>
|
||||
<th>Exercise</th>
|
||||
<th>Sets:</th>
|
||||
<th>Reps:</th>
|
||||
@for ($i = 0; $i < count)
|
||||
<tr>
|
||||
<td>{{ $goal }}</td>
|
||||
<td>{{ $preferences }}</td>
|
||||
<td>{{ $experience }} months</td>
|
||||
<td>{{ $experience }}</td>
|
||||
<td>{{ $frequency }} days per week</td>
|
||||
</tr>
|
||||
</table>--}}
|
||||
<br style="clear:both;" />
|
||||
</table>
|
||||
@endfor
|
||||
</div>
|
||||
@endsection
|
BIN
workoutgenerator.dump
Normal file
BIN
workoutgenerator.dump
Normal file
Binary file not shown.
Loading…
Reference in a new issue