PHPackages                             san4io/eloquent-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. san4io/eloquent-filter

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

san4io/eloquent-filter
======================

Laravel Eloquent Filter Package

0.2(8y ago)1185MITPHPPHP &gt;=7.1

Since Oct 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/san4io/eloquent-filter)[ Packagist](https://packagist.org/packages/san4io/eloquent-filter)[ RSS](/packages/san4io-eloquent-filter/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

EloquentFilter
==============

[](#eloquentfilter)

[![Build Status](https://camo.githubusercontent.com/6aab3bbd67f5ad871f9ce8bd14155a64b21525a6b53af9f2f4a0a46607d6a743/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616e34696f2f656c6f7175656e742d66696c7465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/san4io/eloquent-filter/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/adf023dc55c3a1f24e575cbdc706007d665437f3aa69e449cf0686a43dd9fdf4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616e34696f2f656c6f7175656e742d66696c7465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/san4io/eloquent-filter/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/7b26056859c9299aba6b4b8cbf9ed6b6fea8e9c49a72616c7682efb9fe18dcb4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f73616e34696f2f656c6f7175656e742d66696c7465722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/san4io/eloquent-filter/?branch=master)

Package to filter your Eloquent model simply and elegantly.

Requirements
------------

[](#requirements)

- "php": "&gt;=7.1",
- "illuminate/support": "5.\*",
- "illuminate/database": "5.\*"

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

[](#installation)

```
composer require san4io/eloquent-filter
```

Usage
-----

[](#usage)

**Model**

Add **Filterable** trait to your eloquent model.

Create **$filterable** property with mappings corresponding to how model attributes should be filtered.

```
class Event extends Model
{
    use Filterable;

    protected $fillable = [
        'country_id',
        'title',
    ];

    protected $filterable = [
        'country_id' => WhereFilter::class,
        'title' => LikeFilter::class,
        'created_at' => BetweenFilter::class
    ];
}
```

**Controller**

Just pass Request params to filter as array.

```
public function index(Request $request): JsonResponse
{
    $events = Event::filter($request->all())->paginate(); // or get(), first() or whatever

    return response()->json($events);
}
```

**Request examples**

`http://localhost/api/v1/events?country_id=101&title=Sport`

`http://localhost/api/v1/events?country_id[]=101&country_id[]=102&title=Sport`

`http://localhost/api/v1/events?created_at[from]=2017-07-11&created_at[till]=2017-08-11&title=Sport`

### Filters

[](#filters)

The package was build with mind that it should be easily extensible, that's why if you need some custom filters, you can extend AbstractFilter and add necessary mapping to the model.

By default where are 3 filter types:

- WhereFilter
- LikeFilter
- BetweenFilter

#### WhereFilter

[](#wherefilter)

Accepts integer or array of integers

#### LikeFilter

[](#likefilter)

Accepts string

#### BetweenFilter

[](#betweenfilter)

Accepts array with keys \['from'\] and \['till'\]

Road map
--------

[](#road-map)

- Tests
- Filtering Relations

Contribution
------------

[](#contribution)

Any contributions welcome!

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Total

2

Last Release

3162d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12079341?v=4)[Aleksandr G](/maintainers/san4io)[@san4io](https://github.com/san4io)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/san4io-eloquent-filter/health.svg)

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

###  Alternatives

[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

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

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[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)[clickbar/laravel-magellan

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

438834.4k1](/packages/clickbar-laravel-magellan)[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)
