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(3y ago)158612MITPHP

Since Jul 8Pushed 3y 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 1mo 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 75% 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

1447d 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.8k52.4M9.4k](/packages/illuminate-database)[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)

PHPackages © 2026

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