Download the PHP package laravelway/query-filters without Composer
On this page you can find all versions of the php package laravelway/query-filters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravelway/query-filters
More information about laravelway/query-filters
Files in laravelway/query-filters
Package query-filters
Short Description Laravel package for filtering models via query string
License MIT
Homepage https://github.com/laravelway/query-filters
Informations about the package query-filters
Readme
This package can be used for filtering eloquent using query string.
First you have to use QueryFilters
trait in your model.
Then you can use addQueryFilters
scope on your model to add any filters you want.
- Using array of filters
In this case it will filter by name parameter and email parameter from query string.
-
You can call
addQueryFilters
multiple times. It will merge all filters together. -
You can use callbacks as filters.
- You can use filters classes to define all filters there. In that case class must be extended from
FiltersAbstract
class.
As you can see, you can define standard filters in $filters
property as array,
or you can define custom functions which are prefixed with filter
word.
In our case filterSearch
is using as filtering function, it means that it will filter
by query parameter search
.
There are some standard filtering classes you can use for filtering.
EqualFilter
it filters for exact value.
ContainsFilter
It filters rows which are contains that value in any part of string.
ContainsInFilter
This filter can be used if we need to filter for value can be found on multiple columns. Usually it used then user types something in one search input, but we must filter rows where that value can be found on one of the following columns.
LikeFilter
This filter is similar to ContainsFilter, but contains will find in any part of string, but with like filter, you can specify in query string via * which part of string sould contain a value.
TrashedFilter
This filter is using to filter deleted rows if model uses SoftDeletes trait.
DateFilter
This filter is using for filter dates.
TODO
- test sorting
- filter relations
- sort relations
- include relations into response
All versions of query-filters with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0