Show only table options in the filter

I have a table where I have modified the getEloquentQuery and in the active filters I want to show only the options that I show in the table. Example, in the customers table I can have options that I am not showing in the order resource, how can I only show the options displayed in the table?
4 Replies
toeknee
toeknee14mo ago
You would need to look to get the table query and use that within the filters query
H.Bilbao
H.BilbaoOP14mo ago
Thank you for your response, but I don't see how to do it. Now I only have this:
->relationship('customer', 'name')
->relationship('customer', 'name')
I understand that you mean adding modifyQueryUsing?
toeknee
toeknee14mo ago
see: https://filamentphp.com/docs/2.x/tables/filters#relationship-select-filters Notice how you can modify the query? So you can use the same method
H.Bilbao
H.BilbaoOP14mo ago
Could this be the best way to do it?
->relationship('customer', 'name', fn (Builder $query) => $query->whereIn('id', TicketResource::getEloquentQuery()->pluck('customer_id')))
->relationship('customer', 'name', fn (Builder $query) => $query->whereIn('id', TicketResource::getEloquentQuery()->pluck('customer_id')))
Want results from more Discord servers?
Add your server