laravel - Nested eager loading with constraint not working -


i having hard time using nested constraint. can me group subjects based on semester 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'] $subject) <tr>     <td>{{ $subject->subject_code }}</td>     <td>{{ $subject->subject_description }}</td>     <td>{{ $subject->units }}</td>     <td></td>     <td>98</td> </tr> @endforeach 


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo