I am having hard time using nested with with constraint. Can someone help me to group subjects based on the what semester it will be offered.
MyController
public function show($id)
{
$student = Student::with(['course', 'course.curriculum', 'course.curriculum.subjects' => function($query){
$query->groupBy('sem_offered');
}])->findOrFail($id);
return view('students.show', compact('student'));
}
show.index
@foreach($student->course->curriculum->subjects['first first-sem'] as $subject)
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>98</td>
</tr>
@endforeach
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire