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 2d 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 32% 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

3116d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01483fcdda66c1a9389afd9e48829f17a4c22561da1be56b4fdd91b5e14d801d?d=identicon)[san4io](/maintainers/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

[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)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

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