© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•3y ago•
6 replies
Pasindu

Load different data based on the role

Hi guys, My project has 2 roles, "admin" and "contractor". There is a ClientCaseResource and If the logged in user is an admin, I want to list down all the client cases in the table. If the logged in uses is a contractor, I want to list down the client cases which are assigned only to that user. How to achieve this in Filament? TIA!
Solution
$table
->modifyQueryUsing(
    fn (Builder $query) => $query->when(
        auth()->user()->hasRole('contractor'),
        fn (Builder $query) => $query->where('user_id', auth()->id())
    )
)
$table
->modifyQueryUsing(
    fn (Builder $query) => $query->when(
        auth()->user()->hasRole('contractor'),
        fn (Builder $query) => $query->where('user_id', auth()->id())
    )
)
Jump to solution
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

How to show a different Filament Panel based on the user role?
FilamentFFilament / ❓┊help
3y ago
How to load different table columns based on screen size?
FilamentFFilament / ❓┊help
8mo ago
Role based access
FilamentFFilament / ❓┊help
2y ago
How to load different ListPage based on permission on multi-tenant resource?
FilamentFFilament / ❓┊help
12mo ago