© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
2 replies
morty

Struggling with an "active" filter and scope on a resource

I have an account resource. The database table has a
inactive_flag
inactive_flag
column that is a
Y
Y
or
N
N
value.

I want my account resource table to be only active accounts by default, and the ability to include inactive with a filter. I also want my global search to only search active accounts, and the view page of the account to not care whether it's active or inactive.

At first I implemented a global scope to scope active only by default. This works great for the table listing and global search. I can use a filter to include inactive by removing the global scope on the base query. However, my problem occurs when I want to navigate to the view page of the account, then the global scope applies again and I get a
404
404
. I'm not sure how I can remove the global scope on the view page of the account?

Alternatively I tried without global scopes and modifying the initial query of the table to include
->where('inactive_flag', '!=', 'Y')
->where('inactive_flag', '!=', 'Y')
which works, but then my filter doesn't work to include inactive because if I use either the
query
query
or
baseQuery
baseQuery
methods, it still results in a query that does this:
where inactive_flag != 'Y' and inactive_flag = 'Y'
where inactive_flag != 'Y' and inactive_flag = 'Y'
which obviously no accounts will match.

How do I solve this?
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

Custom Filter and Query Scope
FilamentFFilament / ❓┊help
3y ago
Active resource
FilamentFFilament / ❓┊help
3y ago