© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
dotdotdot

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());
                });
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Select Relationship Modify Query Using
FilamentFFilament / ❓┊help
2y ago
Modify Query Using with Live
FilamentFFilament / ❓┊help
11mo ago
soft delete modify query using
FilamentFFilament / ❓┊help
16mo ago
Nested relationship managers
FilamentFFilament / ❓┊help
3y ago