F
Filament2mo ago
DSM

How to access filter values in other filter field in table filter

As shown in the attached image, I want to add query in brand_id and grade_id which include cargo_id, so when cargo_id is selected the qiery is applied and related records are loaded
No description
8 Replies
Bruno Pereira
Bruno Pereira2mo ago
You can customize the relationship query using
->relationship('author', 'name', fn (Builder $query) => $query->withTrashed())
->relationship('author', 'name', fn (Builder $query) => $query->withTrashed())
https://filamentphp.com/docs/4.x/tables/filters/select#customizing-the-select-filter-relationship-query in your case
->relationship('author', 'name', fn (Builder $query, Get $get) => $query->... $get('cargo_id'))
->relationship('author', 'name', fn (Builder $query, Get $get) => $query->... $get('cargo_id'))
Might work
DSM
DSMOP2mo ago
first solution didn't worked Then I tried by injecting BaseFilters but i don't know which method to use to get the value of filter
Bruno Pereira
Bruno Pereira2mo ago
trial and error. did you dd($filter) to see what it has
DSM
DSMOP2mo ago
I tried using dd($filter) but i am little confused. The response i received is attached as image can u help me with this
DSM
DSMOP2mo ago
.
No description
Bruno Pereira
Bruno Pereira2mo ago
seeing the print, you must access $filter -> table -> filters, dont know if there's a $filter->getTable()->getFilters or something you gotta figure it out because I never needed to use this check if BaseFilter class has any functions that can help you

Did you find this page helpful?