Download the PHP package morningtrain/laravel-filters without Composer
On this page you can find all versions of the php package morningtrain/laravel-filters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download morningtrain/laravel-filters
More information about morningtrain/laravel-filters
Files in morningtrain/laravel-filters
Package laravel-filters
Short Description Query filters for Laravel
License GPL-3.0-only
Informations about the package laravel-filters
Laravel Filters
This package provides a series of filters that can be used to constrain a Laravel DB Query based on request values.
Installation
Via Composer
Included Filters
All filters can be used using the base Filter class at:
MorningTrain\Laravel\Filters\Filter.
It should not be confused with MorningTrain\Laravel\Filters\Filters\Filter
that are the base class all filters are extending.
Basic
Filter by a basic variable static variable.
The following example look for filter_request_parameter
in the request, and apply it to the query for the column of the same name.
It corresponds to:
Like in the following example, it is possible to add a closure as the second parameter.
The closure will get the query as well as the filter value as parameters. It makes it possible to apply some custom logic.
Always
Always run a closure and apply something to the query.
With
Eager load relations on the query.
Paginate
Apply pagination to the query. It is important that this filter is applied last.
It expects the request values $page and $per_pageto be present.
Order
The order filter can be configured to sort the data by specific columns or using scopes.
To specify the columns to sort by, call the only method on the filter.
The following example will look for sort[id] and sort[created_at] in the request.
The values of sort[<column_name>] can be either asc or desc.
Calling the scope method, it is possible to also configure any scopes to be used. It will be looking in the request for any sort keys that match the scope name.
Default values can also easily be added:
Credits
This package is developed and actively maintained by Morningtrain.
_- _ -__ - -- _ _ - --- __ ----- _ --_
( Morningtrain, Denmark )
`---__- --__ _ --- _ -- ___ - - _ --_ ´
o
. ____
_||__| | ______ ______ ______
( | | | | | | |
/-()---() ~ ()--() ~ ()--() ~ ()--()
--------------------------------------All versions of laravel-filters with dependencies
illuminate/http Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0
illuminate/support Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0
illuminate/database Version ^5.8|^6.0|^7.0|^8.0|^9.0|^10.0
morningtrain/laravel-support Version ^1.0