How to filter Filament table by nested relationship?
The structure of tables are like this: acc->user->role
now I'm in
now I'm in
acc
resource and I want to filter the rows based on user roles. How can I do that?5 Replies
Filament
Getting started - Resources - Admin Panel - Filament
The elegant TALL stack admin panel for Laravel artisans.
I added this. then how should my code be like? I tried this: SelectFilter::make('user.role')
->options(UsersRoles::all()->pluck('role', 'id'))
->label('user role'),
but didnt work
ahh, ok. You can use:
and return the query with the filters... Other example here https://filamentphp.com/docs/2.x/tables/filters#custom-filter-forms
Filament
Filters - Table Builder - Filament
The elegant TALL stack table builder for Laravel artisans.
Are you using the Spatie package to manage roles/permissions?
No actually these roles are a little bit different. but I'm now able to do that using
whereHas
in the query. Thanks!