Generate form now redirects to a new page, favicon changed, work on admin pages begun - specifically for exercises management, lots of backend development for generator done, workout generation coming soon.

This commit is contained in:
William Brawner 2015-09-05 21:34:27 -07:00
parent ce60756360
commit 23c5a18d9b
15 changed files with 383 additions and 77 deletions

View file

@ -0,0 +1,21 @@
<?php
namespace WorkoutGenerator\Http\Controllers;
use Illuminate\Http\Request;
use WorkoutGenerator\Http\Requests;
use WorkoutGenerator\Http\Controllers\Controller;
use WorkoutGenerator\Exercise;
class ExercisesController extends Controller
{
public function index() {
$exercises = Exercise::all();
return view('exercises.index')->with('exercises', $exercises);
}
public function create() {
return view('exercises.add');
}
}

View file

@ -2,10 +2,11 @@
namespace WorkoutGenerator\Http\Controllers; namespace WorkoutGenerator\Http\Controllers;
use Illuminate\Http\Request; use Request;
use WorkoutGenerator\Http\Requests; use WorkoutGenerator\Http\Requests;
use WorkoutGenerator\Http\Controllers\Controller; use WorkoutGenerator\Http\Controllers\Controller;
use WorkoutGenerator\Exercise;
use DB;
class GeneratorController extends Controller class GeneratorController extends Controller
{ {
@ -16,72 +17,104 @@ class GeneratorController extends Controller
*/ */
public function index() public function index()
{ {
return view('generate'); return view('generator/generate');
} }
/** public function generate()
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{ {
// $input = Request::all();
$goal = Request::get('goal');
$sets = 0;
$reps = "";
switch ($goal) {
case "strength":
$sets = 8;
$reps = "1-6";
break;
case "endurance":
$sets = 3;
$reps = "15-25";
break;
case "definition":
$sets = 4;
$reps = "8-12";
break;
default:
$sets = 3;
$reps = "10";
};
$preferences = [
Request::get('free_weights'),
Request::get('dumbbells'),
Request::get('barbells'),
Request::get('selectorized'),
Request::get('cables'),
Request::get('calisthenics')
];
if (isset($preferences)) {
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 = [];
function getExercises($muscle, $preference) {
$exercises = DB::table('exercises')
->where('exercise_type', $preference)
->where('muscle_group', $muscle)
->lists('exercise_name');
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));
};
};
$years = intval(Request::get('years'));
$months = intval(Request::get('months'));
$total = ($years * 12) + $months;
$experience = 0;
switch ($total) {
case ($total >= 24):
$experience = 3;
break;
case ($total > 6):
$experience = 2;
break;
default:
$experience = 1;
};
$frequency = intval(Request::get('frequency'));
$large_muscle = 3;
$small_muscle = 2;
return view('generator/workout', [
'goal' => $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)
]);
} }
}
/**
* Store a newly created resource in storage.
*
* @param Request $request
* @return Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param Request $request
* @param int $id
* @return Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return Response
*/
public function destroy($id)
{
//
}
}

View file

@ -26,7 +26,7 @@ class PagesController extends Controller
public function generate() public function generate()
{ {
return view('generate'); return view('generator/generate');
} }
/** /**

View file

@ -17,3 +17,8 @@ Route::get('/about', 'PagesController@about');
Route::get('/generate', 'PagesController@generate'); Route::get('/generate', 'PagesController@generate');
Route::get('/exercises', 'ExercisesController@index');
Route::get('/exercises/create', 'ExercisesController@create');
Route::post('/generate/workout', 'GeneratorController@generate');

View file

@ -6,7 +6,8 @@
"type": "project", "type": "project",
"require": { "require": {
"php": ">=5.5.9", "php": ">=5.5.9",
"laravel/framework": "5.1.*" "laravel/framework": "5.1.*",
"illuminate/html": "^5.0"
}, },
"require-dev": { "require-dev": {
"fzaninotto/faker": "~1.4", "fzaninotto/faker": "~1.4",

48
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"hash": "9b17480643a3385848d169584a3ae257", "hash": "2618ca87ca2b8b0f1430af64e18d9ed2",
"packages": [ "packages": [
{ {
"name": "classpreloader/classpreloader", "name": "classpreloader/classpreloader",
@ -216,6 +216,52 @@
], ],
"time": "2014-12-20 21:24:13" "time": "2014-12-20 21:24:13"
}, },
{
"name": "illuminate/html",
"version": "v5.0.0",
"source": {
"type": "git",
"url": "https://github.com/illuminate/html.git",
"reference": "3d1009bb8e0f25720c914af5c1f4015dd373c9ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/illuminate/html/zipball/3d1009bb8e0f25720c914af5c1f4015dd373c9ef",
"reference": "3d1009bb8e0f25720c914af5c1f4015dd373c9ef",
"shasum": ""
},
"require": {
"illuminate/http": "~5.0",
"illuminate/session": "~5.0",
"illuminate/support": "~5.0",
"php": ">=5.4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"psr-4": {
"Illuminate\\Html\\": ""
},
"files": [
"helpers.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylorotwell@gmail.com"
}
],
"time": "2015-01-01 16:31:18"
},
{ {
"name": "jakub-onderka/php-console-color", "name": "jakub-onderka/php-console-color",
"version": "0.1", "version": "0.1",

View file

@ -126,6 +126,7 @@ return [
Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Html\HtmlServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class, Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class,
@ -172,7 +173,9 @@ return [
'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class,
'Event' => Illuminate\Support\Facades\Event::class, 'Event' => Illuminate\Support\Facades\Event::class,
'File' => Illuminate\Support\Facades\File::class, 'File' => Illuminate\Support\Facades\File::class,
'Form' => Illuminate\Html\FormFacade::class,
'Hash' => Illuminate\Support\Facades\Hash::class, 'Hash' => Illuminate\Support\Facades\Hash::class,
'Html' => Illuminate\Html\HtmlFacade::class,
'Input' => Illuminate\Support\Facades\Input::class, 'Input' => Illuminate\Support\Facades\Input::class,
'Inspiring' => Illuminate\Foundation\Inspiring::class, 'Inspiring' => Illuminate\Foundation\Inspiring::class,
'Lang' => Illuminate\Support\Facades\Lang::class, 'Lang' => Illuminate\Support\Facades\Lang::class,

View file

@ -175,6 +175,7 @@ body {
text-shadow:0px 0px 5px #000; text-shadow:0px 0px 5px #000;
border:1px solid #000; border:1px solid #000;
padding:3px 5px; padding:3px 5px;
cursor: pointer;
} }
.generator input[type='checkbox'] { .generator input[type='checkbox'] {
@ -184,6 +185,7 @@ body {
border:1px solid #000; border:1px solid #000;
padding:5px; padding:5px;
margin:0 5px 0 0; margin:0 5px 0 0;
cursor: pointer;
} }
.generator input[type='checkbox']:disabled { .generator input[type='checkbox']:disabled {
@ -195,6 +197,21 @@ body {
background-repeat: no-repeat; background-repeat: no-repeat;
} }
.workout {
width:75%;
border:1px solid black;
margin:auto;
text-align:center;
}
.workout th, .workout tr, .workout td {
border:1px solid black;
}
.workout th {
font-weight: bold;
}
@media (max-width: 1024px) { @media (max-width: 1024px) {
.generator { .generator {
background-position: right bottom; background-position: right bottom;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 0 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -0,0 +1,14 @@
@extends('layouts.master')
@section('title', 'Add an Exercise')
@endsection
{{!! Form::open() !!}}
{{!! Form::text('Name') !!}}
{{ Form::close() !!}}
@section('content')
@endsection

View file

@ -0,0 +1,17 @@
@extends('layouts.master')
@section('title', 'Add an Exercise')
@section('header')
@section('content')
<div class="content">
<h1>Add a New Exercise</h1>
<fieldset>
{!! Form::open() !!}
{!! Form::text('name', null, ['placeholder'=>'Name']) !!}
{!! Form::close() !!}
</fieldset>
</div>
@endsection

View file

@ -0,0 +1,22 @@
@extends('layouts.master')
@section('title', 'Exercises')
@section('content')
<div class="content">
<table>
<tr>
<td>Name</td>
<td>Muscle Group</td>
<td>Type</td>
</tr>
@foreach ($exercises as $exercise)
<tr>
<td>{{ $exercise->exercise_name }}</td>
<td>{{ $exercise->muscle_group }}</td>
<td>{{ $exercise->exercise_type }}</td>
</tr>
@endforeach
</table>
</div>
@endsection

View file

@ -2,15 +2,14 @@
@section('title', 'Generate') @section('title', 'Generate')
@section('header')
@section('content') @section('content')
<div class="content" style="padding-bottom:0;"> <div class="content" style="padding-bottom:0;">
<h1>Workout Generator</h1> <h1>Workout Generator</h1>
<div class="generator"> <div class="generator">
<div class="fs-div"> <div class="fs-div">
<form method="post"> <form method="post" action="/generate/workout">
<fieldset> <fieldset>
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<legend>Background Info:</legend> <legend>Background Info:</legend>
<label>What is your primary goal?:</label> <label>What is your primary goal?:</label>
<br /> <br />
@ -26,7 +25,7 @@
<label>Which of the following equipment/exercise styles do you have access to and enjoy doing? Check all that apply:</label> <label>Which of the following equipment/exercise styles do you have access to and enjoy doing? Check all that apply:</label>
<br /> <br />
<br /> <br />
<input type="checkbox" name="free-weights" id="free-weights" value="free-weights" onClick="control()">Free Weights <input type="checkbox" name="free_weights" id="free-weights" value="free_weights" onClick="control()">Free Weights
<br /> <br />
<input type="checkbox" name="dumbbells" id="dumbbells" value="dumbbells" disabled><span class="dtext">Dumbbells</span> <input type="checkbox" name="dumbbells" id="dumbbells" value="dumbbells" disabled><span class="dtext">Dumbbells</span>
<br /> <br />
@ -34,7 +33,7 @@
<br /> <br />
<input type="checkbox" name="selectorized" value="selectorized">Selectorized Equipment <input type="checkbox" name="selectorized" value="selectorized">Selectorized Equipment
<br /> <br />
<input type="checkbox" name="cables" value="cables">Cable Equipment <input type="checkbox" name="cable" value="cable">Cable Equipment
<br /> <br />
<input type="checkbox" name="calisthenics" value="calisthenics">Calisthenics <input type="checkbox" name="calisthenics" value="calisthenics">Calisthenics
<br /> <br />
@ -51,7 +50,7 @@
<select name="months"> <select name="months">
<?php <?php
for ($i = 0; $i <= 11; $i++) { for ($i = 0; $i <= 11; $i++) {
echo '<option value="{$i}">' . $i . ' months</option>'; echo "<option value=\"{$i}\">{$i} months</option>";
} }
?> ?>
</select> </select>
@ -64,7 +63,7 @@
<select name="frequency"> <select name="frequency">
<?php <?php
for ($i = 1; $i <= 6; $i++) { for ($i = 1; $i <= 6; $i++) {
echo '<option value="{$i}">' . $i . '</option>'; echo "<option value=\"{$i}\">{$i}</option>";
} }
?> ?>
</select> </select>

View file

@ -0,0 +1,102 @@
@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="cables" value="cables">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

View file

@ -0,0 +1,26 @@
@extends('layouts.master')
@section('title', 'Home')
@section('header')
@section('content')
<div class="content">
<h1>Your Workout, Should You Choose to Accept It...</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>
<tr>
<td>{{ $goal }}</td>
<td>{{ $preferences }}</td>
<td>{{ $experience }} months</td>
<td>{{ $frequency }} days per week</td>
</tr>
</table>--}}
<br style="clear:both;" />
</div>
@endsection