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

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

hugorut/filterable
==================

A laravel package for working with query filtering

0.0.1(10y ago)020MITPHPPHP &gt;=5.4.0

Since Dec 6Pushed 10y agoCompare

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

READMEChangelogDependencies (2)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/90e13beceeb9ea3d131e2b234f6e96a81dde7ab18359b2462abfb1f12ccaab7e/68747470733a2f2f7472617669732d63692e6f72672f6875676f7275742f66696c74657261626c652e706e67)](https://travis-ci.org/hugorut/filterable)\#Fiterable **A package which provides a fluent interface to apply constraints to an Eloquent query**

For example:

```
#Set the package to run all constraints against an Article model
$filter = Filter::setType('articles');

#filter those articles by the Page and Author model so that only
#articles that appear with these contraints are returned
$filter->only([
    'pages' => [1, 2],
    'authors' => [4, 7, 9]
])->get();
```

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

[](#installation)

First, pull in the package through Composer.

```
composer require hugorut/filterable
```

Include the service provider within `config/app.php`.

```
'providers' => [
    Hugorut\Filter\Laravel\FilterServiceProvider::class,
];
```

Add the facade alias to this same file at the bottom:

```
'aliases' => [
    'Filter'    => Hugorut\Filter\Laravel\Filter::class,
];
```

Then publish the package assets by running in your project root

```
php artisan vendor:publish
```

You should see a terminal output similar to:

```
Copied File [/vendor/Filter/src/Hugorut/Filter/config.php] To [/config/filter.php]
Publishing complete for tag []!
```

Usage
-----

[](#usage)

**Config**

First you need to provide the package with knowledge of what models are filterable and which can have filters applied to them. Add your settings to the package configuration file which located at `app\config\filter.php` after you have published the package assets.

Add models you wish to apply filters to in the *Builders* array

```
'Builders' => [
    'articles' => 'App\Article'
],
```

Add models you wish to filter by in the *Filters* array

```
'Filters' => [
    'pages' => 'App\Page',
    'authors' => 'App\Author'
],
```

**API**

It is highly recommended that you use the Filter facade or dependency injection to access the package functionality as this the class has a number of depencies which the laravel IOC container can rectify.

Using the Filter class is simple, first set a model you wish to appy filters against (and which has been aliased in the filter config file).

```
$filter = Filter::setType('articles');
```

Now the filter is configured to the correct model you can call either the `only` or the `without` methods on the filter.

```
$filter->only(['pages' => [1, 2]]);
/*-----
* or
-----*/
$filter->without(['pages' => [1, 2]]);
```

The parameters of both of these methods are an assoicative array. The keys of this associative array are the model aliases (as defined in your `app\config\filter.php` config file) and the values are an array of the ids of these models.

Call the `get` method on the filter to then query the database and return the filtered results.

```
$filter->get();
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

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

Unknown

Total

1

Last Release

3859d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6455139?v=4)[Hugo Rut](/maintainers/hugorut)[@hugorut](https://github.com/hugorut)

---

Top Contributors

[![hugorut](https://avatars.githubusercontent.com/u/6455139?v=4)](https://github.com/hugorut "hugorut (27 commits)")

---

Tags

laravelormeloquent

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sofa/model-locking

Pseudo pessimistic model locking with broadcasted events for Laravel Eloquent ORM.

4848.1k](/packages/sofa-model-locking)[matchory/elasticsearch

The missing elasticsearch ORM for Laravel!

3061.7k](/packages/matchory-elasticsearch)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3729.5k3](/packages/wayofdev-laravel-cycle-orm-adapter)[chocofamilyme/laravel-tarantool

A Tarantool based Eloquent ORM and Query builder for Laravel

182.3k](/packages/chocofamilyme-laravel-tarantool)[andreagroferreira/laravel-sync-tracker

A Laravel package for tracking entity synchronization status between systems

123.6k](/packages/andreagroferreira-laravel-sync-tracker)

PHPackages © 2026

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