Automatic url parameter mapping to sort, filter, include and select data in an easy to use fluent api within Laravel 5. The default parameter structure is compatible to the http://jsonapi.org specification.
ricktap/qriteria is a Laravel package for automatic url parameter mapping to sort, filter, include and select data in an easy to use fluent api within laravel 5. the default parameter structure is compatible to the http://jsonapi.org specification..
It currently has 6 GitHub stars and 44 downloads on Packagist (latest version 0.6.1).
Install it with composer require ricktap/qriteria.
Discover more Laravel packages by ricktap
or browse all Laravel packages to compare alternatives.
Last updated
Home of Qriteria: https://github.com/ricktap/Qriteria
Qriteria is a frankenword containing the terms Query and Criteria. It is intended to take the $_GET Parameters of a request and maps the words filter, fields, sort, include and limit as described in the JSON API Specification to the query of an eloquent model.
Qriterias fluent Api allows for three query hooks:
composer require ricktap/qriteria
add the following to your config/app.php inside the providers array
RickTap\Qriteria\QriteriaServiceProvider::class,
To configure Qriteria, you can generate the config/qriteria.php config file by running the command:
php artisan vendor:publish
filter=name:like:John%,(age:gt:60|age:lt:20),status:eq:occupied
$query->where("name","LIKE","John%")->where(function ($q) {
return $q->where("age",">",60)->orWhere("age","<",20);
})->where("status","=","occupied");
Every filter statement consists of three parts, separated by colons (:). The first part represents the field to query, the second part is the operation, that is available as a symbol or a word (i.e. you can use = or eq for the same thing) the third part is the value to compare to. the filter statements are separated by a comma (,) or a pipe (|). The comma means and the pipe means or. Statements can be wrapped into parenthesis like in a mathematical function, to sort their execution sequence.