Download the PHP package mjedari/larafilter without Composer
On this page you can find all versions of the php package mjedari/larafilter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mjedari/larafilter
More information about mjedari/larafilter
Files in mjedari/larafilter
Package larafilter
Short Description Simple laravel query string based filter package
License MIT
Homepage https://github.com/mjedari/larafilter
Informations about the package larafilter
Laravel Query String Filter
This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.
Quick start
Create a filter
Implement your filter logic
In the filter class which is created, implement your login in the apply()
method.
In order to get query value just use $this->value
. We retrieved it for you from your request.
Register filter class for model
Before registering you should use Filterable
trait in your model.
Use it!
Installation
You can install the package via composer:
Then you can publish config file:
Usage
Initiation
Its simple.First create a filter by this command:
Command will create a class under the default directory App\Filters
:
Your filter logic would be implemented in the apply()
method:
The important thing is that you have access query string value by $this->value
in your filter class.
Using
For Which model you want to filter you should add Filterable
trait in it.
Then add related filters that you created. It should be static property:
Every thing is ready. just use it in your queries:
if you want to specify some filter you can pass them thought this method:
It's good to mention that this package works with query string. Ex:
So you should pass params through the url. The default query name is filter class name. Of course you can change the filters query name by:
Also, you can set rules on your query string parameters:
More than that sometimes we would like cast query string value. So:
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.