Download the PHP package kblais/query-filter without Composer
On this page you can find all versions of the php package kblais/query-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download kblais/query-filter
More information about kblais/query-filter
Files in kblais/query-filter
Package query-filter
Short Description Easily create filters for your Eloquent models.
License MIT
Informations about the package query-filter
QueryFilter
Easily create filters for your Eloquent model.
Based on Jeffray Way's Laracast tutorial.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Usage
A QueryFilter is a class to apply, based on an array or a Request, multiple conditions.
You can call any Eloquent method directly from filter methods.
To allow a model to use query filters, you have to add the Filterable
trait on your model.
You can then use the filter()
scope from anywhere:
If your filter parameters are always placed in an array key (for example filters
), you can define the default-filters-source
config key in the config file, or add a protected string $source = 'filters'
in your QueryFilter.
Frequent issues
Call to an undefined method App\QueryFilters\YourFilter::anEloquentScope().
with PHPStan
To fix this error message, add the following DocBlock to your filter:
Testing
The test suite is composed of 3 tests: PHPCsFixer (coding style), PHPStan (static analysis) and PHPUnit (unit tests).
You can run all these tests running the following command:
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
- Follow the PSR-2 Coding Standard. Use PHP-CS-Fixer to apply the conventions.
- Add tests for the features you add and bugs you discover.
Credits
- Killian BLAIS
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of query-filter with dependencies
illuminate/database Version ^9.33|^10.0|^11.0
illuminate/http Version ^9.33|^10.0|^11.0
illuminate/support Version ^9.33|^10.0|^11.0
spatie/laravel-package-tools Version ^1.1