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 e69de29..5496d29 100644 Binary files a/public/favicon.ico and b/public/favicon.ico differ 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') +
Name | +Muscle Group | +Type | +
{{ $exercise->exercise_name }} | +{{ $exercise->muscle_group }} | +{{ $exercise->exercise_type }} | +