Ejemplo n.º 1
0
 /**
  *
  * @return Workout
  */
 private function createWorkout($name, $seriesIds)
 {
     $workout = new Workout(['name' => $name]);
     $workout->user()->associate($this->user);
     $workout->save();
     //Attach the exercise series
     $workout->series()->attach($seriesIds);
     return $workout;
 }
 /**
  * Get all the user's workouts with the contents of each workout
  * @return mixed
  */
 public function getWorkouts()
 {
     $workouts = Workout::forCurrentUser()->get();
     //get all the series that are in each workout
     foreach ($workouts as $workout) {
         $workout->contents = $workout->series()->select('exercise_series.id', 'name')->orderBy('name', 'asc')->get();
     }
     return $workouts;
 }