PHPackages                             ravaelles/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. [Search &amp; Filtering](/categories/search)
4. /
5. ravaelles/filterable

ActiveLibrary[Search &amp; Filtering](/categories/search)

ravaelles/filterable
====================

Package for handling record filtering in Laravel 5.\*

v2.1.2(8y ago)4406MITHTMLPHP &gt;=5.3.0CI failing

Since Nov 19Pushed 8y ago2 watchersCompare

[ Source](https://github.com/Ravaelles/Filterable)[ Packagist](https://packagist.org/packages/ravaelles/filterable)[ Docs](https://github.com/Ravaelles/Filterable)[ RSS](/packages/ravaelles-filterable/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (7)Dependencies (3)Versions (12)Used By (0)

Filtering and searching Eloquent records for Laravel 5.\*
=========================================================

[](#filtering-and-searching-eloquent-records-for-laravel-5)

[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Package to handle filtering of records in Laravel 5.\*, ready to work with MongoDB.

Define filters easily. Save time by using provided bootstrap view which displays all the filters and properly styles select elements (and far more!). Oh, and there's also a nice search box, too! :)

Install
-------

[](#install)

Via Composer

```
$ composer require ravaelles/filterable
```

Usage
-----

[](#usage)

**(1)** Open `config/app.php` and add to the end of providers this entry:

```
\Ravaelles\Filterable\FilterableServiceProvider::class,

```

---

**(2)** Now open command line in root of your project and publish a view:

```
php artisan vendor:publish

```

Feel free to modify it, it's now in `resources\views\packages\filterable\filtering.blade.php`

---

**(3)** Notice that `filtering.blade.php` uses `@push('scripts')` operator. It appends all the javascript scripts to the end of the html, when jQuery has already been loaded to avoid `jQuery is not defined` error. To make it work, please add `@stack('scripts')` part just after you load your last script using `` tag. Notice the `@stack` blade operator is available since about Laravel 5.2.20.

---

**(4)** Now in your model add this trait:

```
use Ravaelles\Filterable\Filterable as Filterable;
(..)
class MyModelName extends Model
{
    use Filterable; // Add trait
```

Every model that you want to be filterable will need this trait.

---

**(5)** It's time to define filters to be used (variable `$filters`). We will define some example filters so you can see how it works. In your controller, just where you retrieve the records, add this:

```
$filters = [

    // First filter
    'status' => [ // Db field name
        'Status' => [ // Field name to be shown for user
            1 => "Created", // [Values => Display names] for select element
            2 => "Awaiting signature",
            3 => "Canceled",
            4 => "Signed",
        ]
    ],

    // Second filter
    'template_id' => [
        'Template' => [0 => "No", 1 => "Yes"]
        // 'Template' => Template::orderBy('id', -1)->pluck('name', 'id')->all() // Or use something like this
    ],

    // You can add more filters here
    //'field_name' => [
    //     'Display name' => ["black" => "Black tea", "green" => "Green tea"]
    //],
];

$users = User::orderBy('id')
	->filterable($filters)
	->paginate(10);
```

Notice that you can apply your own, custom `where` clauses just before the `->filterable` part.

---

**(6)** Finally, in your view add this line which will automatically display the filters using selects:

```
@include('vendor.filterable.filtering')
```

Feel free to modify this file as you wish.

---

**(7)** If you wish to use search box functionality then make sure to add `->searchable()` line in your controller like this:

```
$users = User::orderBy('id')
    ->searchable()
	->filterable($filters)
	->paginate(10);
```

...and in your model add a list of fields you want to search against e.g.

```
public $searchable = [
    'name', 'email', 'address'
];
```

It will search for text from the search box in any of these fields.

---

**(8)** You are now able to use this package and dynamically filter the records! :)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity65

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

Recently: every ~1 days

Total

10

Last Release

3241d ago

Major Versions

0.4 → v1.02015-11-23

v1.1 → v2.02017-06-24

PHP version history (2 changes)0.1PHP &gt;=5.5.9

0.3PHP &gt;=5.3.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b011dd390fab9e6e389b519ac8898449d28974137eb24b7df0e656c513c453f?d=identicon)[Ravaelles](/maintainers/Ravaelles)

---

Top Contributors

[![Ravaelles](https://avatars.githubusercontent.com/u/5878275?v=4)](https://github.com/Ravaelles "Ravaelles (24 commits)")

---

Tags

laravelfilterrecordsfilterable

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[kyslik/laravel-filterable

Using URL query strings to filter Eloquent queries.

11539.0k](/packages/kyslik-laravel-filterable)[stolz/laravel-html-tidy

HTML Tidy middleware for Laravel

268.7k](/packages/stolz-laravel-html-tidy)

PHPackages © 2026

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