I'm starting to use filters in filamentphp and I would like to know if there is a way to apply a filter and have it remain applied until it is removed manually even if I change sections.
You can use session-based filtering. This will store the filter state in the session, allowing the filter to remain applied across page reloads or navigation within the application.
Here’s how you can achieve this:
Define a filter in your Filament resource using the ->query() method. You can store the selected filter values in the session.
To make sure the filter remains applied when you navigate, you can save the filter value in the session. This can be done by customizing your resource's query method or using the before or after hooks to check the session for filter states.
Persist the filter state across sections. You can use JavaScript or Laravel session-based logic to store the selected filter values in the session. When you change sections, the session will remember the filter and apply it automatically.
To remove the filter, you can add a reset button or a clear filter option that will clear the session value for that filter, which can be handled by a route or an action.
this will apply these settings globally. If you want them in a particular Resource only, use the code again in that resource boot method. As for the original question, $table->persistFiltersInSession(); is what you need.