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
toeknee10mo ago
You would need to look to get the table query and use that within the filters query
H.Bilbao
H.Bilbao10mo 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
toeknee10mo 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.Bilbao9mo 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')))