Modify Query Using nested relationship

Hi, I have an institution resource, every institution belongs to a state and every state belongs to an admin. admin ----has many---> states ---has many----> institutions I want to only show the institutions that belong indirecly to the currently logged in admin, this is what I attempted but it didn't work:
->modifyQueryUsing(function (Builder $query) {
return $query->withWhereHas('state.admin', function (Builder $filter) {
$filter->where('id', auth()->id());
});
->modifyQueryUsing(function (Builder $query) {
return $query->withWhereHas('state.admin', function (Builder $filter) {
$filter->where('id', auth()->id());
});
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server