PHPackages                             laraditz/model-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. laraditz/model-filter

ActiveLaravel-package[Database &amp; ORM](/categories/database)

laraditz/model-filter
=====================

A simple eloquent model filter.

1.0.5(6mo ago)0369MITPHPPHP ^7.4|^8.0

Since Apr 1Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/laraditz/model-filter)[ Packagist](https://packagist.org/packages/laraditz/model-filter)[ RSS](/packages/laraditz-model-filter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (8)Used By (0)

Laravel Model Filter
====================

[](#laravel-model-filter)

[![Latest Stable Version](https://camo.githubusercontent.com/6164852f963642ffcdaafd97e683abc4e58aa5ababec3184586d57838aeb5cb2/68747470733a2f2f706f7365722e707567782e6f72672f6c6172616469747a2f6d6f64656c2d66696c7465722f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/laraditz/model-filter)[![Total Downloads](https://camo.githubusercontent.com/456d48a87654a2be7af5d5a3217a1f1677dc355a3ecf9a022c0fd8c43df37acb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c6172616469747a2f6d6f64656c2d66696c7465723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laraditz/model-filter)[![License](https://camo.githubusercontent.com/7166eed2af92891a0acbbcd3e7483d54c3180fb7f521634e1b862ca05c6b0438/68747470733a2f2f706f7365722e707567782e6f72672f6c6172616469747a2f6d6f64656c2d66696c7465722f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/laraditz/model-filter)[![StyleCI](https://camo.githubusercontent.com/3ebb9759d3748ad0fa1b6c7f477c842a04b4bdc799f75a8b68f3c6d585d07be8/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f373534383938362f736869656c643f7374796c653d737175617265)](https://github.com/laraditz/model-filter)

A simple eloquent model filter for Laravel and Lumen.

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

[](#installation)

Via Composer

```
$ composer require laraditz/model-filter
```

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

[](#configuration)

Add filterable trait to your model as below snippet:

```
use Laraditz\ModelFilter\Filterable;

class User extends Model implements AuthenticatableContract, AuthorizableContract
{
    use Filterable;
    ...
}
```

Create filter class under the `App/Filters` folder with `Filter` format. For example for `User` model, you will need to create `UserFilter` class.

Below snippet shows how the `UserFilter` could look like:

```
namespace App\Filters;

use Laraditz\ModelFilter\Filter;
use Illuminate\Database\Eloquent\Builder;

class UserFilter extends Filter
{
    public function name(string $value)
    {
        $this->where('name', 'LIKE', $value);
    }

    public function email(string $value)
    {
        $this->where('email', 'LIKE', "%$value%");
    }

    // Filter relationship
    public function rank($value)
    {
        $this->whereHas('rank', function (Builder $query) use ($value) {
            $query->where('level', 'like', $value);
        });
    }
}
```

If you want to have more control on which attributes can be filtered, you can add `filterable` array to you model:

```
protected $filterable = [
    'name', 'email'
];
```

Usage
-----

[](#usage)

In your controller, call `filter` method and pass the input data to use the filter that you have created.

```
$users = User::filter($request->all())->get();
```

Your request query strings could look like this.

```
/users?name=farhan&rank=novice

```

You could also pass `sort` param to apply sorting for your result.

```
/users?name=farhan&rank=novice&sort=name,level

```

Sort desc by adding `-` symbol in front of the field name

```
/users?name=farhan&rank=novice&sort=-name,level

```

That's it!

Credits
-------

[](#credits)

- [Raditz Farhan](https://github.com/raditzfarhan)

License
-------

[](#license)

MIT. Please see the [license file](LICENSE) for more information.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance69

Regular maintenance activity

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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 ~336 days

Recently: every ~421 days

Total

6

Last Release

180d ago

PHP version history (3 changes)1.0.0PHP ^7.2.5

1.0.2PHP ^7.2.5|^8.0

1.0.3PHP ^7.4|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1203676?v=4)[Raditz Farhan](/maintainers/raditzfarhan)[@raditzfarhan](https://github.com/raditzfarhan)

---

Top Contributors

[![raditzfarhan](https://avatars.githubusercontent.com/u/1203676?v=4)](https://github.com/raditzfarhan "raditzfarhan (22 commits)")

---

Tags

laravellumenmodeleloquentfilter

### Embed Badge

![Health badge](/badges/laraditz-model-filter/health.svg)

```
[![Health](https://phpackages.com/badges/laraditz-model-filter/health.svg)](https://phpackages.com/packages/laraditz-model-filter)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[dyrynda/laravel-model-uuid

This package allows you to easily work with UUIDs in your Laravel models.

4802.8M8](/packages/dyrynda-laravel-model-uuid)[spiritix/lada-cache

A Redis based, automated and scalable database caching layer for Laravel

591444.8k2](/packages/spiritix-lada-cache)[mohammad-fouladgar/eloquent-builder

527189.5k](/packages/mohammad-fouladgar-eloquent-builder)[mehdi-fathi/eloquent-filter

Eloquent Filter adds custom filters automatically to your Eloquent Models in Laravel.It's easy to use and fully dynamic, just with sending the Query Strings to it.

450191.6k1](/packages/mehdi-fathi-eloquent-filter)

PHPackages © 2026

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