nico-sorice / laravel-query-filterer
A laravel package for filtering queries with http request
Requires
- php: >=7.1.0
- illuminate/container: ~5.5.0|~5.6.0|~5.7.0
- illuminate/contracts: ~5.5.0|~5.6.0|~5.7.0
- illuminate/database: ~5.5.0|~5.6.0|~5.7.0
- illuminate/http: ~5.5.0|~5.6.0|~5.7.0
- illuminate/support: ~5.5.0|~5.6.0|~5.7.0
- illuminate/validation: ~5.5.0|~5.6.0|~5.7.0
This package is auto-updated.
Last update: 2025-03-29 00:41:07 UTC
README
This package allows you to set conditional rules to filter a query according to the HTTP request values with ease and speed.
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
Prerequisites
This package requires php7.0 or up, laravel 5.5 or up and composer installed on your computer.
composer
php >= 7.0.0
laravel >= 5.5
Installation
Require using composer
composer require nico-sorice/laravel-query-filterer
Usage
In your controller
<?php
use NicoSorice\QueryFilterer\PackageClasses\QueryFilterer;
New QueryFilterer(
Model::query(),
request()
)->filter([
'id' => WhereFilter::class,
'status_id' => WhereInFilter::class,
'date' => (new WhereDateBetweenFiter)->setFormat('d/m/Y'),
])
Full list of available filters
The package includes validation rules for the filters that require them
In your request
<?php
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'id' => 'nullable|integer',
'date' => [
'nullable',
new FilterWhereDateBetweenValidationRule
]
];
}
Full list of available validation rules
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Authors
- Nicolas Sorice - Initial work - GitLab Profile
See also the list of CONTRIBUTORS.md who participated in this project.
License
This project is licensed under the MIT License - see the LICENSE.md file for details