Hello, I have following modeling: Atableworkoutsthathasseveralmodelsoftraining(models_treinos).Thetreadmillmodelhasseveralexercises.Inlaravel,Ineedtolistacertainworkout(id1,forexample),allthemodelsofthatworkoutandalltheexercisesofthatmodel.Inthecodebelow,Icanbringthedataofthetrainingandthetrainingmodels,butIcannotbringtheexercisesandtheirdata:
$trainings=TrainingHasModels::with(['models'=>function($query){$query->get()->first();}])->where('training_id',$training->id)->get();
ModelTraining
publicfunctiontrainingStudentExercises(){return$this->hasMany('App\TrainingStudentExercise','training_id');}
ModelTrainingModel
publicfunctiontrainingExercises(){return$this->hasMany('App\TrainingExercise','training_model_id');}