Package Data | |
---|---|
Maintainer Username: | ricktap |
Maintainer Contact: | pselge@gmail.com (Patrick Selge) |
Package Create Date: | 2016-08-11 |
Package Last Update: | 2016-08-13 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-01-25 15:04:23 |
Package Statistics | |
---|---|
Total Downloads: | 43 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
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.