From 23c5a18d9be3998e2d4738148fb8c8938490b456 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Sat, 5 Sep 2015 21:34:27 -0700 Subject: [PATCH] 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. --- app/Http/Controllers/ExercisesController.php | 21 +++ app/Http/Controllers/GeneratorController.php | 167 +++++++++++-------- app/Http/Controllers/PagesController.php | 2 +- app/Http/routes.php | 5 + composer.json | 3 +- composer.lock | 48 +++++- config/app.php | 3 + public/assets/css/styles.css | 17 ++ public/favicon.ico | Bin 0 -> 1150 bytes resources/views/create.blade.php | 14 ++ resources/views/exercises/add.blade.php | 17 ++ resources/views/exercises/index.blade.php | 22 +++ resources/views/generate.blade.php | 13 +- resources/views/generator/generate.blade.php | 102 +++++++++++ resources/views/generator/workout.blade.php | 26 +++ 15 files changed, 383 insertions(+), 77 deletions(-) create mode 100644 app/Http/Controllers/ExercisesController.php create mode 100644 resources/views/create.blade.php create mode 100644 resources/views/exercises/add.blade.php create mode 100644 resources/views/exercises/index.blade.php create mode 100644 resources/views/generator/generate.blade.php create mode 100644 resources/views/generator/workout.blade.php diff --git a/app/Http/Controllers/ExercisesController.php b/app/Http/Controllers/ExercisesController.php new file mode 100644 index 0000000..11f76fb --- /dev/null +++ b/app/Http/Controllers/ExercisesController.php @@ -0,0 +1,21 @@ +with('exercises', $exercises); + } + + public function create() { + return view('exercises.add'); + } +} diff --git a/app/Http/Controllers/GeneratorController.php b/app/Http/Controllers/GeneratorController.php index 98ccb7f..3419733 100644 --- a/app/Http/Controllers/GeneratorController.php +++ b/app/Http/Controllers/GeneratorController.php @@ -2,10 +2,11 @@ namespace WorkoutGenerator\Http\Controllers; -use Illuminate\Http\Request; - +use Request; use WorkoutGenerator\Http\Requests; use WorkoutGenerator\Http\Controllers\Controller; +use WorkoutGenerator\Exercise; +use DB; class GeneratorController extends Controller { @@ -16,72 +17,104 @@ class GeneratorController extends Controller */ public function index() { - return view('generate'); + return view('generator/generate'); } - /** - * Show the form for creating a new resource. - * - * @return Response - */ - public function create() + public function generate() { - // + $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) - { - // - } -} +} \ No newline at end of file diff --git a/app/Http/Controllers/PagesController.php b/app/Http/Controllers/PagesController.php index 8d46e0d..edbbe8b 100644 --- a/app/Http/Controllers/PagesController.php +++ b/app/Http/Controllers/PagesController.php @@ -26,7 +26,7 @@ class PagesController extends Controller public function generate() { - return view('generate'); + return view('generator/generate'); } /** diff --git a/app/Http/routes.php b/app/Http/routes.php index 88c0c92..83a5089 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -17,3 +17,8 @@ Route::get('/about', 'PagesController@about'); Route::get('/generate', 'PagesController@generate'); +Route::get('/exercises', 'ExercisesController@index'); + +Route::get('/exercises/create', 'ExercisesController@create'); + +Route::post('/generate/workout', 'GeneratorController@generate'); \ No newline at end of file diff --git a/composer.json b/composer.json index 68028c2..5430392 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,8 @@ "type": "project", "require": { "php": ">=5.5.9", - "laravel/framework": "5.1.*" + "laravel/framework": "5.1.*", + "illuminate/html": "^5.0" }, "require-dev": { "fzaninotto/faker": "~1.4", diff --git a/composer.lock b/composer.lock index 50d5b7c..870dae0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "9b17480643a3385848d169584a3ae257", + "hash": "2618ca87ca2b8b0f1430af64e18d9ed2", "packages": [ { "name": "classpreloader/classpreloader", @@ -216,6 +216,52 @@ ], "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", "version": "0.1", diff --git a/config/app.php b/config/app.php index 4925038..ad2e96b 100644 --- a/config/app.php +++ b/config/app.php @@ -126,6 +126,7 @@ return [ Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, + Illuminate\Html\HtmlServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, @@ -172,7 +173,9 @@ return [ 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, + 'Form' => Illuminate\Html\FormFacade::class, 'Hash' => Illuminate\Support\Facades\Hash::class, + 'Html' => Illuminate\Html\HtmlFacade::class, 'Input' => Illuminate\Support\Facades\Input::class, 'Inspiring' => Illuminate\Foundation\Inspiring::class, 'Lang' => Illuminate\Support\Facades\Lang::class, diff --git a/public/assets/css/styles.css b/public/assets/css/styles.css index 0d85319..afcba2a 100644 --- a/public/assets/css/styles.css +++ b/public/assets/css/styles.css @@ -175,6 +175,7 @@ body { text-shadow:0px 0px 5px #000; border:1px solid #000; padding:3px 5px; + cursor: pointer; } .generator input[type='checkbox'] { @@ -184,6 +185,7 @@ body { border:1px solid #000; padding:5px; margin:0 5px 0 0; + cursor: pointer; } .generator input[type='checkbox']:disabled { @@ -195,6 +197,21 @@ body { 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) { .generator { background-position: right bottom; diff --git a/public/favicon.ico b/public/favicon.ico index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5496d29456c1ea0c780e58c06f37fb33843b01e4 100644 GIT binary patch literal 1150 zcmbtUu};G<5WTiY3{+4WJFY<1_Zoo+$eR^770Z!7hn9&?_N$J%Hb-N2=@)Tm?QFuXcIsRnK+L?gm>OTjKSKu zNqN0hk>-BIkAAc?4|4ftPYcsRuJ3#1jHp_0D9O^{cELMgF6z7kJ>^A*$!6zaCRa3% z97?kM50{Ii`W@Fi<=j|6wP3x<;?{JrB@&^|1N*_Avd?2)iDpg7;9QHa?U#dHhe}GA zWA?Nn!~Uwe%|k;Y@fn(Ru`ZB%9%vI$CtYL69qboDYvdcH`c-AKqrr`9gl+D{6iifPKliUU-WBI_!b+f{C-iy<~Ew>9V$IGs!w!&6>}(T>kb$ ztyysvmuD}F$2n*_V0{)>h>O6hT|Xk`Cvn*i_R8*UApV)lez2#OduQk4!>-59eOV&v ht`jx(p{5Re17E-;uuW7%SOZ30=ZHS>CwQAD`UQ0a+L-_V literal 0 HcmV?d00001 diff --git a/resources/views/create.blade.php b/resources/views/create.blade.php new file mode 100644 index 0000000..e224267 --- /dev/null +++ b/resources/views/create.blade.php @@ -0,0 +1,14 @@ +@extends('layouts.master') + +@section('title', 'Add an Exercise') +@endsection + +{{!! Form::open() !!}} + + {{!! Form::text('Name') !!}} + +{{ Form::close() !!}} + +@section('content') + +@endsection \ No newline at end of file diff --git a/resources/views/exercises/add.blade.php b/resources/views/exercises/add.blade.php new file mode 100644 index 0000000..57c1709 --- /dev/null +++ b/resources/views/exercises/add.blade.php @@ -0,0 +1,17 @@ +@extends('layouts.master') + +@section('title', 'Add an Exercise') +@section('header') + +@section('content') +
+

Add a New Exercise

+
+ {!! Form::open() !!} + + {!! Form::text('name', null, ['placeholder'=>'Name']) !!} + + {!! Form::close() !!} +
+
+@endsection \ No newline at end of file diff --git a/resources/views/exercises/index.blade.php b/resources/views/exercises/index.blade.php new file mode 100644 index 0000000..0ec7a82 --- /dev/null +++ b/resources/views/exercises/index.blade.php @@ -0,0 +1,22 @@ +@extends('layouts.master') + +@section('title', 'Exercises') + +@section('content') +
+ + + + + + + @foreach ($exercises as $exercise) + + + + + + @endforeach +
NameMuscle GroupType
{{ $exercise->exercise_name }}{{ $exercise->muscle_group }}{{ $exercise->exercise_type }}
+
+@endsection diff --git a/resources/views/generate.blade.php b/resources/views/generate.blade.php index 355e053..1ea35a3 100644 --- a/resources/views/generate.blade.php +++ b/resources/views/generate.blade.php @@ -2,15 +2,14 @@ @section('title', 'Generate') -@section('header') - @section('content')

Workout Generator

-
+
+ Background Info:
@@ -26,7 +25,7 @@

- Free Weights + Free Weights
Dumbbells
@@ -34,7 +33,7 @@
Selectorized Equipment
- Cable Equipment + Cable Equipment
Calisthenics
@@ -51,7 +50,7 @@ @@ -64,7 +63,7 @@ diff --git a/resources/views/generator/generate.blade.php b/resources/views/generator/generate.blade.php new file mode 100644 index 0000000..cc7f068 --- /dev/null +++ b/resources/views/generator/generate.blade.php @@ -0,0 +1,102 @@ +@extends('layouts.master') + +@section('title', 'Generate') + +@section('content') +
+

Workout Generator

+
+
+ +
+ + Background Info: + +
+
+ +
+
+
+ +
+
+ Free Weights +
+ Dumbbells +
+ Barbells +
+ Selectorized Equipment +
+ Cable Equipment +
+ Calisthenics +
+
+
+ +
+
+ + +
+
+
+ +
+
+ +
+
+ +
+ +
+
+
+ +@endsection diff --git a/resources/views/generator/workout.blade.php b/resources/views/generator/workout.blade.php new file mode 100644 index 0000000..8dd88fb --- /dev/null +++ b/resources/views/generator/workout.blade.php @@ -0,0 +1,26 @@ +@extends('layouts.master') + +@section('title', 'Home') + +@section('header') + +@section('content') +
+

Your Workout, Should You Choose to Accept It...

+
+

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

+ {{-- + + + + + + + + + + +
Your Goal:Your Preferred Workout Types:Your Experience:Your Desired Workout Frequency:
{{ $goal }}{{ $preferences }}{{ $experience }} months{{ $frequency }} days per week
--}} +
+
+@endsection \ No newline at end of file