我的項目中有一些模型,在這張圖片中詳細描述了不同的關系:我創建了一些模型來表示每個表。我想知道是否有可能建立關系,允許恢復教師的所有學生或學生的所有教師。例子: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'); }}我正在使用 Laravel 5.8
如何通過其他模型 Laravel 創建關系?
慕的地8271018
2022-06-11 10:38:46