/**
  * Responds to requests to GET /routines/{id}
  */
 public function getShow($id)
 {
     $routine = Routine::with('exercises')->where('slug', $id)->first();
     $recommended_routines = Routine::where('goal_id', $routine->goal_id)->where('id', '<>', $routine->id)->orderBy('name')->take(10)->get();
     $routine_days = RoutineExercise::where('routine_id', $routine->id)->select('day')->groupBy('day')->orderBy('day')->get();
     if (!$routine) {
         return view('errors.404');
     }
     return view('routines.show', ['routine' => $routine, 'recommended_routines' => $recommended_routines, 'routine_days' => $routine_days]);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $user = User::where('email', '*****@*****.**')->first();
     $routine = Routine::firstOrCreate(['name' => 'Two Foot Jump for Athletes', 'goal_id' => 2, 'frequency_id' => 2, 'difficulty_id' => 2, 'description' => 'This routines aimed to help increase two foot jump. It can be very helpful for basketball and volleyball players. Make sure to focus on executing each jumping exercise with maximum speed and force.', 'created_by_id' => $user->id]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 4, 'day' => 1, 'order' => 1, 'reps' => 8, 'sets' => 4, 'rest' => 120]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 8, 'day' => 1, 'order' => 2, 'reps' => 6, 'sets' => 3, 'rest' => 60]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 5, 'day' => 2, 'order' => 1, 'reps' => 8, 'sets' => 4, 'rest' => 120]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 9, 'day' => 2, 'order' => 2, 'reps' => 4, 'sets' => 4, 'rest' => 120]);
     $routine = Routine::firstOrCreate(['name' => 'Bigger Arms', 'goal_id' => 4, 'frequency_id' => 1, 'difficulty_id' => 1, 'description' => 'This routines aimed to help increase upper body muscle size and tone. Make sure perform each exercise in control fashion.', 'created_by_id' => $user->id]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 1, 'day' => 1, 'order' => 1, 'reps' => 12, 'sets' => 4, 'rest' => 90]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 2, 'day' => 1, 'order' => 2, 'reps' => 10, 'sets' => 4, 'rest' => 90]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 3, 'day' => 1, 'order' => 3, 'reps' => 10, 'sets' => 4, 'rest' => 90]);
     RoutineExercise::firstOrCreate(['routine_id' => $routine->id, 'exercise_id' => 7, 'day' => 1, 'order' => 4, 'reps' => 12, 'sets' => 3, 'rest' => 90]);
 }