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())
    )
)
Was this page helpful?