Level 4
$students = Student::
join('group_student', function ($join) use ($group) {
$join->on('group_student.student_id', '=', 'students.id')
->where('group_id', $group->id);
})
->with(['results.grade' => function ($query) use ($paper_ids) {
$query->whereIn('results.paper_id', $paper_ids);
}])
->with('targets.grade')
->orderBy('last_name', 'asc')->get();
This is what I have at the moment which is not returning any "Results" unfortunately without adding another table (which I would rather not do) I cannot just attach a
->with('papers.results.grade')
any ideas?