PHPackages                             rezayavari/querybuilder - 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. [Database &amp; ORM](/categories/database)
4. /
5. rezayavari/querybuilder

ActiveLibrary[Database &amp; ORM](/categories/database)

rezayavari/querybuilder
=======================

4.0.1(8y ago)01331MITPHP

Since Jul 28Pushed 7y agoCompare

[ Source](https://github.com/rezayavari66/querybuilder)[ Packagist](https://packagist.org/packages/rezayavari/querybuilder)[ RSS](/packages/rezayavari-querybuilder/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (6)Versions (28)Used By (1)

Querybuilder
============

[](#querybuilder)

Introduction
------------

[](#introduction)

A Laravel base controller class and a trait that will enable to add filtering, sorting, eager loading and pagination to your resource URLs.

**Dedicated to Giordano Querybuilder**

This package is named after my hero Giordano Bruno. A true visionary who dared to dream beyond what was thought possible. For his ideas and his refusal to renounce them he was burned to the stake in 1600. [I highly recommend this short cartoon on his life narrated by Neil deGrasse Tyson](https://vimeo.com/89241669).

Functionality
-------------

[](#functionality)

- Parse GET parameters for dynamic eager loading of related resources, sorting and pagination
- Advanced filtering of resources using filter groups
- Use [Optimus\\Architect](https://github.com/esbenp/architect) for sideloading, id loading or embedded loading of related resources
- ... [Ideas for new functionality is welcome here](https://github.com/esbenp/bruno/issues/new)

Tutorial
--------

[](#tutorial)

To get started with Bruno I highly recommend my article on [resource controls in Laravel APIs](http://esbenp.github.io/2016/04/15/modern-rest-api-laravel-part-2/)

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

[](#installation)

For Laravel 5.4 and above

```
composer require rezayavari/querybuilder ~4.0
```

Usage
-----

[](#usage)

The examples will be of a hypothetical resource endpoint `/books` which will return a collection of `Book`, each belonging to a `Author`.

```
Book n ----- 1 Author

```

### Available query parameters

[](#available-query-parameters)

KeyTypeDescriptionIncludesarrayArray of related resources to load, e.g. \['author', 'publisher', 'publisher.books'\]SortarrayProperty to sort by, e.g. 'title'LimitintegerLimit of resources to returnPageintegerFor use with limitFilter\_groupsarrayArray of filter groups. See below for syntax.### Implementation

[](#implementation)

```
