Download the PHP package hchamran/laravel-filter without Composer
On this page you can find all versions of the php package hchamran/laravel-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hchamran/laravel-filter
More information about hchamran/laravel-filter
Files in hchamran/laravel-filter
Package laravel-filter
Short Description A package to help you do easily filter for search
License MIT
Homepage https://github.com/hChamran/laravel-filter
Informations about the package laravel-filter
Easily filter and search
Topics
- Introduction
- Concept
- Installation
- Usage
Introduction
Always in laravel, the filter of database fields and search inside that, it's repetitive work, but you can with use this package create filters very easy.
Concept
This work with GET method and query string. When this receives query string, parses this query string to this characters:
Symbol | Do | Usage | Example |
---|---|---|---|
\: | separating field from value | Field:value | title:phone |
- | separating range of values | value1-value2 | price:0-100 |
\, | separating fields fo filter from sort method | Field:value,sort | title:phone,asc |
By | separating field of sorting from sort method | Field:value,sortByField | title:phone,ascByprice |
Installation
(For Laravel <=5.4) Next, you must add the service provider to config/app.php config/app.php
:
Publish your config file
Usage
First use filterable in your model:
Second make filter class with this command for Example:
Third, add fields which you want to search inside it for example for products:
And in final just do search with helper: