PHPackages                             n7olkachev/laravel-filterable - 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. n7olkachev/laravel-filterable

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

n7olkachev/laravel-filterable
=============================

Nice and simple scope for your models

v2.0.0(8y ago)33893MITPHPPHP ^7.0

Since Aug 24Pushed 8y ago1 watchersCompare

[ Source](https://github.com/n7olkachev/laravel-filterable)[ Packagist](https://packagist.org/packages/n7olkachev/laravel-filterable)[ Docs](https://github.com/n7olkachev/laravel-filterable)[ RSS](/packages/n7olkachev-laravel-filterable/feed)WikiDiscussions master Synced 4w ago

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

Laravel Filterable Trait
========================

[](#laravel-filterable-trait)

[![](https://camo.githubusercontent.com/bf145b0037e1d79cc706e3e3d9004c734fb81733ffe45a2e4e431ddb91ed79dd/68747470733a2f2f7765627365637265742e62792f696d616765732f6c6f676f2d6769746875622e706e67)](https://websecret.by)

[![Code quality](https://camo.githubusercontent.com/ff42ad1d54259046803da30f3f28b43fa56c6f9ebaaa4e072c366830f81f3109/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6e376f6c6b61636865762f6c61726176656c2d66696c74657261626c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/n7olkachev/laravel-filterable/)[![Licence](https://camo.githubusercontent.com/e237eb8f38e72531bec1ade5937eac8cb8d590beb3e6d4f9d37e3caafd2ca58d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6e376f6c6b61636865762f6c61726176656c2d66696c74657261626c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/n7olkachev/laravel-filterable)[![Build Status](https://camo.githubusercontent.com/c239db960add2169319572536e70eb05bb0f0060d4482e6321aeb56d0aea5428/68747470733a2f2f7472617669732d63692e6f72672f6e376f6c6b61636865762f6c61726176656c2d66696c74657261626c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/n7olkachev/laravel-filterable)

Why?
----

[](#why)

This package is powered by standard Laravel scopes, instead of other similar packages, that brings something like `Filter` classes to your code, so it is much more easy to jump into. Also, if you decide to remove this package from your project, you will stay with standard scopes which can be used directly further.

Personally, I use this trait for faster development, combining it with `$request->all()`

```
Page::filter($request->all())->get()
```

By default, you get equality filters (`where field = bar`) and when you need to support other queries, adding new scopes will do the trick, without changing anything except model. See examples for better understanding.

Examples
--------

[](#examples)

```
class Page extends Model
{
    use Filterable;

    protected $fillable = [
        'title',
        'status',
        'created_at',
    ];

    protected $filterable = [
        'title',
        'created_after'
    ];

    public function scopeCreatedAfter($query, $time)
    {
        return $query->where('created_at', '>', $time);
    }
}
```

Now, we can use `filter` scope to filter our queries:

```
Page::filter(['title' => 'Cool page'])->first(); // equals to where('title', 'Cool page')

Page::filter(['status' => ['new', 'active'])->get() // equals to whereIn('status', ['new', 'active'])

Page::filter(['created_after' => '2017-01-01'])->get() // equals to createdAfter('2017-01-01') (notice our scope in Page class)
```

Of course it supports filters with multiple keys:

```
Page::filter(['title' => 'Cool page', 'status' => 'active'])->first()
```

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

[](#installation)

You can install the package via composer:

```
composer require n7olkachev/laravel-filterable
```

Next, add Filterable trait and list all filterable properties:

```
use Filterable;

protected $filterable = ['created_at', 'title'];
```

That's all!

Testing
-------

[](#testing)

```
$ composer test
```

Credits
-------

[](#credits)

- [Nikita Tolkachev](https://github.com/n7olkachev)

Sponsored by
------------

[](#sponsored-by)

Web agency based in Minsk, Belarus

License
-------

[](#license)

The MIT License (MIT)

###  Health Score

30

—

LowBetter than 61% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity60

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

Total

3

Last Release

3276d ago

Major Versions

v1.0.1 → v2.0.02017-08-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/b1dde1980432378072b5f61d495c578baeaa3ac833dd16e99a2db03c642e4a9a?d=identicon)[n7olkachev](/maintainers/n7olkachev)

---

Top Contributors

[![n7olkachev](https://avatars.githubusercontent.com/u/3993345?v=4)](https://github.com/n7olkachev "n7olkachev (9 commits)")

---

Tags

laraveleloquentscopesfilterablewebsecret

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/n7olkachev-laravel-filterable/health.svg)

```
[![Health](https://phpackages.com/badges/n7olkachev-laravel-filterable/health.svg)](https://phpackages.com/packages/n7olkachev-laravel-filterable)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k8.9M109](/packages/mongodb-laravel-mongodb)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[kirschbaum-development/eloquent-power-joins

The Laravel magic applied to joins.

1.6k35.7M51](/packages/kirschbaum-development-eloquent-power-joins)[mike-bronner/laravel-model-caching

Automatic caching for Eloquent models.

2.4k161.4k2](/packages/mike-bronner-laravel-model-caching)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8723.3M27](/packages/yajra-laravel-oci8)

PHPackages © 2026

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