Closed NeoKactus closed 5 years ago
How are you using the teachers
relationship?
The goal was to be able to send a query like this to my API.
/api/courses?include=teachers,students&filter[fullname]=Chemistry%209
Query builder to resolve the includes to relationships.
Course ( Contains teachers() ) | CourseSchool -> School (This is the relationship I want to eager load) |
---|
Enrolment | User |
---|
Roles
It's only possible with lazy eager loading:
$courses = Course::with('teachers')->get();
$teachers = $courses->pluck('teachers')->flatten();
$teachers->load('enrolment.school');
I will give it a shot. Thank you for the insight.
The filtering is working as expected but, is there any way to eager load relationships for a intermediate/pivot table?
I tried this as well but I see that hasManyDeepFromRelations doesn't preserve additional constraints. https://github.com/staudenmeir/eloquent-has-many-deep/issues/36#issuecomment-519950021