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

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

alitokmakci/model-filter
========================

A Simple Query Filter For Eloquent Models

1.0.3(4y ago)2158MITPHPPHP ^7.4|^8.0

Since Jul 29Pushed 4y ago1 watchersCompare

[ Source](https://github.com/alitokmakci/LaravelModelFilter)[ Packagist](https://packagist.org/packages/alitokmakci/model-filter)[ RSS](/packages/alitokmakci-model-filter/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (4)Used By (0)

A Simple Query Filter Builder for Laravel Eloquent Models

##### Install:

[](#install)

```
composer require alitokmakci/model-filter

```

##### Creating Filters:

[](#creating-filters)

```
php artisan make:filter {queryName}

```

This command will generate a Filter class in app/Http/Filter directory.

PS: You can use 1 filter for which models you want.

For example:

If you have status column on User model and Transaction model, you can use the Status filter for both User and Transaction models.

Filters are working with column names not with models itself! Feel free to use them!

##### Usage:

[](#usage)

```
use ModelFilter\ModelFilter;

public function index()
{
    $users = ModelFilter::filter(App\Models\User::class,
        [
            App\Http\Filters\Email::class,
            App\Http\Filters\Status::class
        ]
    )->get();

    return response($users);
}

```

#### Examples:

[](#examples)

For given code above:

###### 1

[](#1)

Url: `/users?email=example@example.com`

Executed SQL: `"select * from `users` where `email` = ?"`

###### 2

[](#2)

Url: `/users?email=example@example.com&status=1`

Executed SQL: `"select * from `users` where `email` = ? and `status` = ?"`

##### Methods:

[](#methods)

There is only one available method:

###### filter(string $model, array $filters)

[](#filterstring-model-array-filters)

returns Laravel QueryBuilder so you can chain all Eloquent methods

##### Customizing Filters:

[](#customizing-filters)

Filters are automatically sets column name and query name from its name so you don't have to write any code after creating Filter Object! Yay!

If you want to customize the filter's column name or query parameter you can check below:

###### To change filtered column name on some Filter just add to your custom filter:

[](#to-change-filtered-column-name-on-some-filter-just-add-to-your-custom-filter)

```
protected function setColumn(): string
{
    return 'custom_column_name';
}

```

###### To change the query filter name:

[](#to-change-the-query-filter-name)

```
protected function setQueryFilter(): string
{
    return 'custom_query_filter_name';
}

```

So the filter will add below code to Laravel query builder:

`where('custom_column_name', request('custom_query_filter_name'))`

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Total

3

Last Release

1668d ago

Major Versions

0.0.1 → 1.0.02021-10-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/0ca45c91870e8fbd9c305c80ad2bdf26bd74285169dac496ef784ddc7a088287?d=identicon)[alitokmakci](/maintainers/alitokmakci)

---

Top Contributors

[![alitokmakci](https://avatars.githubusercontent.com/u/46011130?v=4)](https://github.com/alitokmakci "alitokmakci (11 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M545](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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