PHPackages                             duuany/eloquent-filters - 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. duuany/eloquent-filters

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

duuany/eloquent-filters
=======================

A simplest Eloquent query filter package.

2.2(4y ago)158812MITPHPCI failing

Since Jul 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/RocketsLab/eloquent-filters)[ Packagist](https://packagist.org/packages/duuany/eloquent-filters)[ RSS](/packages/duuany-eloquent-filters/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (5)Dependencies (4)Versions (20)Used By (2)

Eloquent Filters
================

[](#eloquent-filters)

##### A simplest Eloquent Model URL query filter package for your Laravel

[](#a-simplest-eloquent-model-url-query-filter-package-for-your-laravel)

Instalation
-----------

[](#instalation)

You can install via composer:

### Laravel 5.5+

[](#laravel-55)

```
$ composer require duuany/eloquent-filters
```

\###Laravel 5.4 or above

```
$ composer require duuany/eloquent-filters:1.1
```

Add the service provider to your config/app.php

```
Duuany\EloquentFilters\EloquentFiltersServiceProvider::class
```

Optionally, you can publish config file to override package configuration

```
$ php artisan vendor:publish --provider="Duuany\EloquentFilters\EloquentFiltersServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

In your model, add the following HasFilters trait

```
class User extends Model
{
    use HasFilters;
}
```

Create a UserFilter class anywhere in your app folder. Filter classes defines array of applicable filters. For each filter added to array of filters, you need to implement the filter logic.

You can create filters via artisan command

```
$ php artisan make:filter FilterName
```

```
class UserFilter extends EloquentFilters
{
    protected $filters = [
        'order', 'popular', ....
    ];

    protected function order($column)
    {
        return $this->builder->orderBy($column, 'desc');
    }
}
```

You can pass multiple parameters to your filters, like this:

```
    protected function order($column, $sort = 'desc')
    {
        return $this->builder->orderBy($column, $sort);
    }
```

When passing more than one paramenter to filter, make sure use a delimiter in your query string.

```
http://myurl.dev?order=id:asc

```

The default delimiter its `:`, but your can modify overriding the `protected $delimiter` property.

##### Example:

[](#example)

```
class UserFilter extends EloquentFilters
{
    protected $delimiter = '|';

    ...
}
```

In query string...

```
http://myurl.dev?order=id|asc

```

... keep in mind, to not use special query strings characters like delimiters.

##### Magic Calls

[](#magic-calls)

Optionally, you can ommit `->builder`:

```
// this...
return $this->builder->orderBy($column, $sort);

// can be called like this...
return $this->orderBy($column, $sort);
```

Now in your application you can use the filters as the following:

```
class UserController extends Controller
{
    public function index(UserFilter $filters)
    {
        $users = User::filter($filters)->get();
    }
}
```

When the user access the URL , the order filter will be applied on the User model.

Testing
-------

[](#testing)

```
$ ./vendor/bin/phpunit
```

Credits
-------

[](#credits)

- [Jeffrey Way](http://laracasts.com)
- [Jorge Junior aka jjquady](http://github.com/jjsquady)
- Many coffee cups :D

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~111 days

Recently: every ~187 days

Total

17

Last Release

1492d ago

Major Versions

1.5 → 2.02019-04-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/eaa735041f66903d9a2873f2e524f9133eae6961f9b9d068510591ba20095dd5?d=identicon)[jjsquady](/maintainers/jjsquady)

---

Top Contributors

[![jjcodes78](https://avatars.githubusercontent.com/u/12722517?v=4)](https://github.com/jjcodes78 "jjcodes78 (23 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/duuany-eloquent-filters/health.svg)

```
[![Health](https://phpackages.com/badges/duuany-eloquent-filters/health.svg)](https://phpackages.com/packages/duuany-eloquent-filters)
```

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.1M11.1k](/packages/illuminate-database)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k29.9M42](/packages/kirschbaum-development-eloquent-power-joins)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.1M23](/packages/yajra-laravel-oci8)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.4M2](/packages/glushkovds-phpclickhouse-laravel)[lemaur/eloquent-publishing

207.8k1](/packages/lemaur-eloquent-publishing)[laravel-liberu/laravel-gedcom

A package that converts gedcom files to Eloquent models

782.5k1](/packages/laravel-liberu-laravel-gedcom)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
