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

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

1766d 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

[jdorn/sql-formatter

a PHP SQL highlighting library

3.8k117.8M121](/packages/jdorn-sql-formatter)[backup-manager/backup-manager

A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.

1.7k1.6M11](/packages/backup-manager-backup-manager)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M88](/packages/propel-propel1)[insolita/yii2-migration-generator

Set of gii tools for generating files for migration by schema of table , phpdoc or table data

108508.0k5](/packages/insolita-yii2-migration-generator)[xpdo/xpdo

A PDO-based Object/Relational Bridge Library

7088.4k4](/packages/xpdo-xpdo)[voku/session2db

A PHP library acting as a wrapper for PHP's default session handling functions which stores data in a MySQL database, providing both better performance and better security and protection against session fixation and session hijacking.

2920.0k](/packages/voku-session2db)

PHPackages © 2026

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