PHPackages                             ricktap/qriteria - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. ricktap/qriteria

ActiveLibrary[API Development](/categories/api)

ricktap/qriteria
================

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.

0.6.1(9y ago)644MITPHPPHP ^5.6 || ^7.0

Since Aug 11Pushed 9y ago2 watchersCompare

[ Source](https://github.com/ricktap/Qriteria)[ Packagist](https://packagist.org/packages/ricktap/qriteria)[ Docs](https://github.com/ricktap/Qriteria)[ RSS](/packages/ricktap-qriteria/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (4)Dependencies (3)Versions (5)Used By (0)

Qriteria
========

[](#qriteria)

Home of 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](http://jsonapi.org/format/#fetching) to the query of an eloquent model.

Qriterias *fluent Api* allows for three query hooks:

- class based pre-hooks, that are run before every query it sends on every instance of your model
- on-call queries, that are called before the translation but after your pre-hook and only for this one instance object
- method-based queries, those are called after the translation and can be used like a scope method in eloquent

Installation
------------

[](#installation)

```
composer require ricktap/qriteria
```

add the following to your config/app.php inside the providers array

```
RickTap\Qriteria\QriteriaServiceProvider::class,
```

Configuration
-------------

[](#configuration)

To configure Qriteria, you can generate the config/qriteria.php config file by running the command:

```
php artisan vendor:publish
```

Filtering
---------

[](#filtering)

### Syntax:

[](#syntax)

```
filter=name:like:John%,(age:gt:60|age:lt:20),status:eq:occupied

```

### Result:

[](#result)

```
$query->where("name","LIKE","John%")->where(function ($q) {
  return $q->where("age",">",60)->orWhere("age","
