Download the PHP package eth0/laravel-filters without Composer
On this page you can find all versions of the php package eth0/laravel-filters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download eth0/laravel-filters
More information about eth0/laravel-filters
Files in eth0/laravel-filters
Package laravel-filters
Short Description A clean laravel model filters where we can filter laravel models by passing query string into it.
License MIT
Informations about the package laravel-filters
Laravel Model Filters
An clean way of filtering laravel models by query strings.
Installation
You can install this package via composer using this command:
The package will automatically register itself, but if your laravel versions is < 5.5
you will need to add
service provider under your file.
Documentation
Once the package is installed there will be 2 new artisan commands.
We can then generate a new model filter just by typing this will generate a new php file under folder with the name which will look like below.
On the variable we can register all our model filters.
However we do not have created yet the model filters so lets create now the model filters.
Note: Pro tip if you add an prefix before your file like below Model a new folder Model will be generated inside your Filters folder so you can keep your filters tidy.
Below is one of the file generated:
On the mappings method we can return an array of mappings for example if we do want to convert a few words to match our database columns like:
Next on the method we can build our query filter like:
Once we have everything ready the last step is to add a scope to our laravel model which this filter will be used.
And then we can use our model filters everywhere on our applications just by adding the filter scope like:
Now we have our filters setup which mean we can now send to our server query string this will return us all the records where the status is active.
Road Map
Here's the plan for what's coming:
- [ ] Add tests.
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see feel free to make any pull request to make this package even better.
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.