Download the PHP package nazalas/laravel-persistent-table-filters without Composer
On this page you can find all versions of the php package nazalas/laravel-persistent-table-filters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nazalas/laravel-persistent-table-filters
More information about nazalas/laravel-persistent-table-filters
Files in nazalas/laravel-persistent-table-filters
Package laravel-persistent-table-filters
Short Description Persist and restore table filter, sort, and search state per user in Laravel applications.
License MIT
Homepage https://github.com/Nazalas/laravel-persistent-table-filters
Informations about the package laravel-persistent-table-filters
Laravel Persistent Table Filters
Automatically persist and restore table filter, sort, and search state per user in Laravel applications. Works great with Livewire.
The Problem
Users refine a table — searching, sorting, filtering — then navigate away or refresh. Everything resets. This package silently saves filter state as users interact and restores it automatically on the next visit. Optionally, users can also save named filter presets and switch between them.
Features
- Auto-persist — silently saves filter state on every change; restores it on mount with no user interaction
- Named presets — users can save, label, and reload specific filter configurations
- Default preset — mark one named preset as the default fallback
- Per-user, per-resource — state is scoped to the authenticated user and a resource key you define
- Opt-out — set
$autoSaveFilters = falseon any component to disable auto-persist
Installation
Publish and run the migration:
Optionally publish the config:
Usage
Livewire Component
Add the HasPersistentFilters trait, define a resource key and which properties make up your filter state:
That's the core usage. Filters now survive page refreshes automatically with no user action needed.
Disabling Auto-Persist
Set $autoSaveFilters = false on any component to prevent persistFilters() from writing to the database:
Clearing Persisted State
Wipes the auto-persisted record for the current user + resource. The next page load will start fresh (or fall back to a named default if one exists).
Named Presets (Optional)
On top of auto-persist, users can save and reload named filter configurations.
Saving a Preset
Loading a Preset
Deleting a Preset
Listing Presets
Example Blade UI for Presets
How Restore Priority Works
restoreFilters() follows this order:
- Auto-persisted state — the last state saved by
persistFilters()(if any) - Named default — a named preset marked
is_default = true(if no auto state) - Component defaults — the property values you declared in the class (if neither exists)
Using Without Livewire
The TableFilter model and scopes work independently of Livewire:
Configuration
Testing
Changelog
See CHANGELOG.md.
License
MIT. See LICENSE.