belongsToMany( 'App\Models\Teacher', 'exam_teacher_rel', 'exam_id', 'teacher_id' ); } public function students() { return $this->belongsToMany( 'App\Models\Student', 'exam_student_rel', 'exam_id', 'student_id' ); } public function exam_results() { return $this->belongsToMany( 'App\Models\ExamResult', 'exam_exam_result_rel', 'exam_id', 'exam_result_id' ); } public function subject() { return $this->belongsTo('App\Models\Subject'); } }