Download the PHP package milito/query-filter without Composer
On this page you can find all versions of the php package milito/query-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download milito/query-filter
More information about milito/query-filter
Files in milito/query-filter
Package query-filter
Short Description This is package to use query filter for each model. This package is made entirely for personal use. But if you are eager to use this, you can easily use this package by using readme. This is very simple and amateur :).
License MIT
Informations about the package query-filter
Laravel Query filter package
A simple package for adding your query filter files to project.
Introduction
Install the package with composer using the following command:
Usage
For create new query filter you can run this command in your terminal:
Example:
This command will create a ProductsFilter.php
file in app/Filters/
path.
This ProductsFilter class, is extended from QueryFilter
class, and it used for controller functions.
And because of that, constructor of this class requires a request
object.
But if you want to create a filter class with a simple array
input, you need to
use -a|--array
option after your class name.
This ProductsFilter class, is extended from ArrayQueryFilter
.
Namespace
You can add namespace to your file:
The above will create a Products
directory inside the app/Filters
directory.
How to use!
After file generated you should add your functions.\ Example:
HINT: If your function parameters don't have default values, you need to fill with value every time you want to use it.
Then you need to add QueryFilterScope
to your model.\
Example :
Now you can use in your controller :
or :
You can use request()
function to get request from filter if you need request.\
Example:
To use a class that inherits from ArrayQueryFilter
:
License
The Milito Query Filter package is open-sourced package licensed under the MIT license.