/**
  * 
  *
  * 
  */
 public function generateLogFromWK(Request $request)
 {
     $planExercises = PlanExercise::with('planSets')->where('plan_workout_id', '=', $request->input('id'))->get();
     foreach ($planExercises as $planExercise) {
         $session = new Session();
         $session->exercise_id = $planExercise->exercise->id;
         $session->session_date = Carbon::now();
         Auth::user()->sessions()->save($session);
         foreach ($planExercise->planSets as $planSet) {
             $sessionSet = new SessionSet();
             $sessionSet->session_id = $session->id;
             $sessionSet->number_of_reps = $planSet->expected_reps;
             $sessionSet->weight_lifted = $planSet->expected_weight;
             $sessionSet->one_rep_max = $sessionSet->weight_lifted * 36 / (37 - $sessionSet->number_of_reps);
             $sessionSet->failed = 0;
             $sessionSet->save();
             $exercise = Auth::user()->exercises()->findOrFail($sessionSet->session->exercise_id);
             $bestOneRepMax = SessionSet::join('sessions', 'sessions.id', '=', 'session_sets.session_id')->where('sessions.exercise_id', '=', $exercise->id)->max('one_rep_max');
             $exercise->update(['best_one_rep_max' => $bestOneRepMax]);
         }
     }
     return redirect()->action('LogController@showLog');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $planSet = PlanSet::findOrFail($id);
     $planExercise = PlanExercise::with('planSets', 'planWorkout')->findOrFail($planSet->plan_exercise_id);
     return view('plans.editPlanSets', compact('planExercise'));
 }