I have some models in my project with differents relations detailed in this picture:
I created some models to represents each tables.
And I would to know if there is a possibility to create relationship that allows to recover all the students of teachers or all the teachers of students.
Example:
class Student extends Model
{
public function clases(){
return $this->hasMany(Clase::class, 'student_id');
}
/** This function doesn't works, not the great relation */
public function teachers(){
return $this->hasManyThrough(Clase::class, Teacher::class, 'student_id', 'teacher_id');
}
}
I'm using Laravel 5.8
Thank in advance
via Chebli Mohamed

Aucun commentaire:
Enregistrer un commentaire