0
Hello, I have following modeling: A training table that has several training models (workouts). The models table has several exercises. At the Laravel, I need to list a particular workout (id 1, for example), all the models of this workout and all the exercises of this model. In the code below, I can bring the training data and training models, but I can’t bring the exercises and their data:
$trainings = TrainingHasModels::with(['models' => function($query){
$query
->get()
->first();
}])
->where('training_id', $training->id)
->get();
Model Training
public function trainingStudentExercises()
{
return $this->hasMany('App\TrainingStudentExercise','training_id');
}
Model Trainingmodel
public function trainingExercises()
{
return $this->hasMany('App\TrainingExercise','training_model_id');
}
show how the Model’s code is workouts and the Model of models_workouts
– Tácio Brito
Also put the model classes
– novic
I edited the question with the modules
– Edinho Rodrigues