/**
  * 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]);
 }
 /**
  * Responds to requests to GET /profile/routines
  */
 public function getRoutines()
 {
     $current_user = Auth::user();
     $routines = Routine::where('created_by_id', $current_user->id)->get();
     return view('profile.routines', ['routines' => $routines]);
 }
 /**
  * Responds to requests to POST /routines/delete/{id}
  */
 public function postDelete($id)
 {
     $routine = Routine::find($id);
     if (!$this->isAdminOrCreator($routine)) {
         return response('Unauthorized.', 401);
     }
     $routine->exercises()->detach();
     $routine->delete();
     \Session::flash('flash_message', 'Routine has been deleted.');
     return redirect('routines');
 }