Listing in

Asked

Viewed 163 times

0

Hello, I have following modeling: inserir a descrição da imagem aqui 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'); 
}

inserir a descrição da imagem aquiinserir a descrição da imagem aqui

  • show how the Model’s code is workouts and the Model of models_workouts

  • Also put the model classes

  • I edited the question with the modules

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.