Download the PHP package mammothcoding/laravel-easy-filter without Composer
On this page you can find all versions of the php package mammothcoding/laravel-easy-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mammothcoding/laravel-easy-filter
More information about mammothcoding/laravel-easy-filter
Files in mammothcoding/laravel-easy-filter
Package laravel-easy-filter
Short Description Easy filter and sorter for indexlike requests
License MIT
Informations about the package laravel-easy-filter
laravel-easy-filter
Readme in other languages: RU
Table of Content
- Requirements
- Introduction
- Installation
- Usage
- Simple Examples
- All filtering methods
- Methods
- License
:electric_plug: Requirements
- PHP 7.4+
- Laravel 6.0+
:microphone: Introduction
Easy filter and sorter for indexlike requests and listings of models. It is possible to use several methods of filtering in a query and sorting the result.
:electric_plug: Installation
Run this Composer command to install the latest version
$ composer require mammothcoding/laravel-easy-filter
Usage
For usage you need to form the correct request to the server and process it in our filtering service to get the result in a convenient form.
-
Format of get request headers:
for filtering:
for sorting:
Simple Examples
-
An example of processing an index request on the server to get a list of users of the User model in the route body in /routes/web.php :
-
An example of a get request for a model list with a specific value of one column:
-
An example of a get-request for a model list with a specific ending in the value of one column:
Actions in code:
-
An example of a get request for a model list with several filtering, sorting and pagination methods:
Actions in code:
-
An example of a query for a model list with filtering and multiple sorting, sorting will be applied sequentially:
Actions in code:
All filtering methods
Methods in the 2nd value in the array of filtering rule:
Example: filter=[["created_at","<"
,"2023-01-01"]]
#
-
Standard mathematical comparison operators
=, <>, >, >=, <, <=
-
in
Selection of the values present in the specified.
Example: filter=[["groups","in",["medics","programmers"]]]
-
notin
Selecting values that are not present in the specified ones.
Example: filter=[["groups","notin",["medics","programmers"]]]
-
between
Selection values from the specified range.
Example: filter=[["created_at","between",["2023-07-14T18:27:59.000000Z","2023-07-19T18:29:58.000000Z"]]]
-
notbetween
Selects values that are not within the specified range.
Example: filter=[["created_at","notbetween",["2023-07-14T18:27:59.000000Z","2023-07-19T18:29:58.000000Z"]]]
-
startswith
Selects values that start with the specified value.
Example: filter=[["created_at","startswith","2023-07-14"]]
-
endswith
Selects values that end with the specified value.
Example: filter=[["email","endswith",".com"]]
-
contains
Selects values that contain the specified value.
Example: filter=[["name","contains","Dr."]]
-
notcontains
Selects values that do not contain the specified value.
Example: filter=[["name","notcontains","Dr."]]
Methods
Methods of class EasyFilter:
-
filter()
Adds filtering conditions to the object's builder.
-
sort()
Adds sort conditions to the object's builder.
-
getResultBuilder()
Get the resulting object's builder directly as an Eloquent Builder.
-
getResultCollection()
Get result from object as Collection.
-
getResultArray()
Get the result from an object as array.
License
All versions of laravel-easy-filter with dependencies
illuminate/support Version >=v6.0.0
illuminate/container Version >=v6.0.0
illuminate/database Version >=v6.0.0
illuminate/pagination Version >=v6.0.0
illuminate/http Version >=v6.0.0
ext-json Version >=v6.0.0