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

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

mdsys/filterable
================

Laravel package for dynamically filtering Eloquent results using URL query string.

322[1 issues](https://github.com/tinchogon34/filterable/issues)PHP

Since Mar 29Pushed 12y ago1 watchersCompare

[ Source](https://github.com/tinchogon34/filterable)[ Packagist](https://packagist.org/packages/mdsys/filterable)[ RSS](/packages/mdsys-filterable/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Filterable
==========

[](#filterable)

This package gives you a convenient way to automatically filter Eloquent results based on query string parameters in the URL. Filterable parses the query string, compares it with columns that you'd like to automatically filter, then creates a dynamic scope that is used by Eloquent to construct the SQL.

- [Installation](#installation)
- [Copyright &amp; License](#license)
- [Usage](#usage)
    - [Single Value](#single-value)
    - [Multiple Values](#multiple-values)
    - [Multiple Parameters](#multiple-parameters)
    - [Boolean Operators](#boolean-operators)
    - [Comparison Operators](#comparison-operators)

Installation
====================================================

[](#installation)

Add the package to 'require' in your composer.json file:

```
"require": {
    "heroicpixels/filterable": "dev-master"
},

```

Run 'composer dump-autoload' from the command line:

```
#composer dump-autoload

```

Register the service provider in 'app/config/app.php'. Service provider:

```
'providers' => array(
    \\...
    'Heroicpixels\Filterable\FilterableServiceProvider',
    \\...
);

```

License
==========================================

[](#license)

Copyright 2014 Dave Hodgins Released under MIT license (). See LICENSE file for details. Usage
===================================================================================================================================================================

[](#copyright-2014-dave-hodginsreleased-under-mit-license-httpopensourceorglicensesmit--see-license-file-for-detailsusage)

Edit your Eloquent model to extend 'Heroicpixels\\Filterable\\Filterable'.

```
class Object extends Heroicpixels\Filterable\Filterable {
    // ...
}

```

In the above example, class Object corresponds to table 'objects':

idcolorshapetotal1redsquare1502bluesquare20003greencircle5754yellowtriangle155redtriangle9006redtriangle600Filterable Columns
------------------

[](#filterable-columns)

Specify the column you want to automatically filter.

```
$columns = [ 'color', 'shape', 'total' ];

```

For example:

```
 http://www.your-site/?color=blue&shape=round&total=500

```

You can also alias the columns if you prefer not to reveal them:

```
$columns = [ 'col' => 'color', 'sha' => 'shape', 'tot' => 'total' ];

```

For example:

```
http://www.your-site/?col=blue&sha=round&tot=500

```

To filter results, simply pass the columns to Eloquent using filterColumns():

```
$objects = Object::filterColumns($columns)->get()->toArray();

```

You can also filter joins:

```
$columns = array('color' => 'objects.color',
                 'name' => 'objects.name',
                 'shape' => 'objects.shape',
                 'category' => 'cat_object.cat_id');
$objects = Object::join('cat_object', 'objects.id', '=', 'cat_object.object_id')
                   ->filterColumns($columns)
                   ->get()->toArray();

```

And you can filter eager loads:

```
/**
 * Columns available in main query
 */
$columns = array('color' => 'objects.color',
                 'name' => 'objects.name',
                 'shape' => 'objects.shape');
$objects = Object::with(array('categories' => function($q) {
               /**
                * Columns available to sub-query
                */
               $columns = array('category' => 'cat_object.cat_id');
               $q->filterColumns($columns);
           }))->filterColumns($columns)
           ->get()
           ->toArray();

```

The following examples demonstrate how query string parameters can be used. Single Value
--------------------------------------------------------------------------------------------------------------------------------

[](#the-following-examples-demonstrate-how-query-string-parameters-can-be-usedsingle-value)

```
?color=red

SELECT ... WHERE ... color = 'red'

```

idcolorshapetotal1redsquare1505redtriangle9006redtriangle600Multiple Values---

```
?color[]=red&color[]=blue

SELECT ... WHERE ... color = 'red' OR color = 'blue'

```

idcolorshapetotal1redsquare1502bluesquare20005redtriangle9006redtriangle600Multiple Parameters---

```
?color[]=red&shape[]=triangle

SELECT ... WHERE ... color = 'red' AND shape = 'triangle'

```

idcolorshapetotal5redtriangle9006redtriangle600Boolean Operators---

```
?color[]=red&shape[]=triangle&bool[shape]=or

SELECT ... WHERE ... color = 'red' OR shape = 'triangle'

```

idcolorshapetotal4yellowtriangle155redtriangle9006redtriangle600Comparison Operators---

**Greater Than**

```
?total=599&operator[total]=>

SELECT ... WHERE ... total > '599'

```

idcolorshapetotal2bluesquare20005redtriangle9006redtriangle600**Less Than**

```
?total=600&operator[total]=<

SELECT ... WHERE ... total < '600'

```

idcolorshapetotal1redsquare1503greencircle5754yellowtriangle15**Not Equal**

```
?shape=triangle&operator[shape]=!=

SELECT ... WHERE ... shape != 'triangle'

```

idcolorshapetotal4yellowtriangle155redtriangle9006redtriangle600**Between**

```
?total[start]=900&total[end]=5000

SELECT ... WHERE ... total BETWEEN '900' AND '5000'

```

idcolorshapetotal2bluesquare20005redtriangle900

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70.4% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8b9146f4e2de2caff702473b628450a8eabb52a2a90a5b2b831cbdb0ef9b5270?d=identicon)[tinchogon34](/maintainers/tinchogon34)

---

Top Contributors

[![heroicpixels](https://avatars.githubusercontent.com/u/6350892?v=4)](https://github.com/heroicpixels "heroicpixels (19 commits)")[![tinchogon34](https://avatars.githubusercontent.com/u/1757985?v=4)](https://github.com/tinchogon34 "tinchogon34 (8 commits)")

### Embed Badge

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

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

###  Alternatives

[ruflin/elastica

Elasticsearch Client

2.3k50.4M203](/packages/ruflin-elastica)[opensearch-project/opensearch-php

PHP Client for OpenSearch

15024.3M65](/packages/opensearch-project-opensearch-php)[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

934529.3k2](/packages/mailerlite-laravel-elasticsearch)[massive/search-bundle

Massive Search Bundle

721.4M13](/packages/massive-search-bundle)[shyim/opensearch-php-dsl

OpenSearch/Elasticsearch DSL library

175.9M9](/packages/shyim-opensearch-php-dsl)[outl1ne/nova-multiselect-filter

Multiselect filter for Laravel Nova.

45802.7k3](/packages/outl1ne-nova-multiselect-filter)

PHPackages © 2026

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