PHPackages                             thalfm/laravel-eloquent-filter - 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. thalfm/laravel-eloquent-filter

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

thalfm/laravel-eloquent-filter
==============================

Allows filtering Eloquent queries by input filters

v1.0.0(6y ago)0190MITPHP

Since Jun 12Pushed 6y agoCompare

[ Source](https://github.com/thalfm/laravel-eloquent-filter)[ Packagist](https://packagist.org/packages/thalfm/laravel-eloquent-filter)[ RSS](/packages/thalfm-laravel-eloquent-filter/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)Dependencies (5)Versions (7)Used By (0)

Laravel Eloquent Filter
=======================

[](#laravel-eloquent-filter)

This module lets you filter Eloquent data using query filters. You can apply WHERE filters and also set order of results

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

[](#installation)

1. Run

    ```
    composer require thalfm/laravel-eloquent-filter
    ```

    in console to install this module
2. That's it! Installation is complete. You don't need to adjust any config or install service providers.

Getting started
---------------

[](#getting-started)

Let's assume you want to allow to filter users data. By default you use `User` Eloquent model to get users. To enable filtering, open User model (by default `app/User.php` file) and add into it the following trait:

```
use \Thalfm\LaravelEloquentFilter\Traits\Filterable;
```

just bellow opening class definition, so it should look something like this:

```
class User extends Authenticatable
{
    use \Thalfm\LaravelEloquentFilter\Traits\Filterable;
```

To allow filtering for this class, you need to also create implementation of `Thalfm\LaravelEloquentFilter\Contracts\QueryFilter` interface. To do that create min `app/Filters` directory file with the following content:

```
