Download the PHP package oooiik/laravel-query-filter without Composer
On this page you can find all versions of the php package oooiik/laravel-query-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download oooiik/laravel-query-filter
More information about oooiik/laravel-query-filter
Files in oooiik/laravel-query-filter
Package laravel-query-filter
Short Description A clean, convention-based way to extract Eloquent query filters into dedicated filter classes â keep your controllers and scopes thin.
License MIT
Homepage https://github.com/oooiik/laravel-query-filter
Informations about the package laravel-query-filter
Laravel Query Filter
A clean, convention-based way to extract Eloquent query filters into dedicated filter classes. Keep your controllers thin, your scopes focused, and your filtering logic testable.
Features
- ðŊ Convention over configuration â each public method on your filter class becomes a filter key. No registration, no metadata.
- ðŠķ Single trait + base class â add
Filterableto a model, point it at a filter class, done. - ð Artisan generator â
php artisan make:filter UserFilterscaffolds the class for you. - ð Composable â apply multiple parameter sets to the same filter instance and chain into the query.
- âïļ Defaults & fallbacks â provide default parameter values and fallback handlers for missing keys.
- ð§Đ Laravel 6 â 12 â broad compatibility, PHP 7.3+ through 8.x.
Installation
The service provider is auto-registered via Laravel's package discovery.
Quick Start
1. Generate a filter
This creates app/Filters/UserFilter.php.
2. Define your filter methods
Each public method becomes a filter key matching its name:
3. Attach the filter to your model
4. Use it
Missing keys are silently ignored â only the filter methods that match input parameters run.
Advanced Usage
Default parameters
Use the $default property to pre-fill values when a key is missing from the input:
Calling User::filter([]) will still apply status = active and sort by created_at desc.
Fallback methods
Use $fallback to redirect missing input keys to a different method:
If the search key is missing from input, searchByName runs with whatever value was provided as the fallback source.
Standalone filter instance (chaining)
Apply multiple parameter sets to the same filter:
Accessing all parameters
Filter methods receive the full parameter array as a second argument:
Comparison with spatie/laravel-query-builder
laravel-query-filter |
spatie/laravel-query-builder |
|
|---|---|---|
| Approach | Convention-based â method = filter key | Declarative â register allowed filters explicitly |
| Per-model class | Yes, dedicated filter class | Optional, often inline |
| Custom filter logic | Plain PHP method | AllowedFilter::callback() |
| Best for | Complex filtering with reusable logic | API endpoints with simple filtering needs |
Both are great â choose laravel-query-filter when you want a dedicated class per model with reusable, testable filter logic.
Requirements
- PHP 7.3 or higher
- Laravel 6.x â 12.x
Compatibility Matrix
| Laravel | PHP | Status |
|---|---|---|
| 12.x | 8.2+ | â Supported |
| 11.x | 8.2+ | â Supported |
| 10.x | 8.1+ | â Supported |
| 9.x | 8.0+ | â Supported |
| 8.x | 7.3+ | â Supported |
| 7.x | 7.3+ | â Supported |
| 6.x | 7.3+ | â Supported |
Contributing
Pull requests are welcome. For substantial changes, please open an issue first to discuss the direction.
Bug reports and feature ideas â GitHub Issues.
Credits
- Obidjon Toshev â author & maintainer
- All contributors
License
The MIT License (MIT). See LICENSE for details.
All versions of laravel-query-filter with dependencies
illuminate/console Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0
illuminate/support Version ^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0