Custom page with table and filters

Hello, I'm having an issue with my custom page where I use a table and table filters, for some reason the applied filters does not end up into my url Here is how I use it: ```php class Planning extends Page implements HasForms, HasTable { use InteractsWithTable; use InteractsWithPageFilters; use InteractsWithForms; public static function table(Table $table): Table { return $table ->query(Planning::all()) ->filters([ Filter::make('year') ->columns(2) ->form([ Select::make('year') ->label('Select year') ->options( collect(range(date('Y'), date('Y') - 10)) ->mapWithKeys(fn($year) => [$year => $year]) ->toArray() ) ->searchable(), ]) } the filters do get applied, but I don't see the active filters applied in my page url Any help would be appriciated. Thanks
4 Replies
arnaudsf
arnaudsf2mo ago
If you set a custom Filter, you have to use a query. Otherwise, how laravel know what to do ? As well, you can use ->whereYear($year) in your query
jamesro
jamesroOP2mo ago
@arnaudsf i do use the filters values in my query, but still, i don't see those filters applied in my browser url as they are normally showing for a resource page
arnaudsf
arnaudsf2mo ago
Could you provide full code ?
jamesro
jamesroOP2mo ago
seems in order to work so that the filters appear on my url when filters are applied, you need to add this on the page:
protected $queryString = [
'tableSortColumn',
'tableSortDirection',
'tableSearchQuery' => ['except' => ''],
'tableFilters',
];
protected $queryString = [
'tableSortColumn',
'tableSortDirection',
'tableSearchQuery' => ['except' => ''],
'tableFilters',
];
Want results from more Discord servers?
Add your server