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

ActiveLibrary

dansmith/eloquent-filterable
============================

Filter scope for Eloquent models

13.5kPHP

Since Oct 13Pushed 8y ago1 watchersCompare

[ Source](https://github.com/DanSmith83/eloquent-filterable)[ Packagist](https://packagist.org/packages/dansmith/eloquent-filterable)[ RSS](/packages/dansmith-eloquent-filterable/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#Eloquent Filterable

A simple package for filtering records, using varying user input.

\##Installation

Add the package to your composer.json file and run composer update:

```
{
	"require" : {
	  "dansmith/eloquent-filterable": "dev-master"
	}
}
```

\##Basic Use

Import the trait and use in your Eloquent model

```
use DanSmith\Filterable\Filterable;

class Page extends Model {

    use Filterable;

}
```

Specify the attributes you want to filter by (any values not specified here will be ignored):

```
protected $filterable = ['category_id', 'created_by'];
```

Alternatively, if you want to provide more complex filters, you can override the getFilterable method. This makes it possible to provide either a closure or a custom class.

```
public function getFilterable()
{
    return [
    	'category_id',
    	'created_by',
    	'starts_with' => function($query, $value) { return $query->where('title', 'LIKE', $value.'%'); }
    ];
}
```

Run an Eloquent query with using your parameters

```
$parameters = ['category_id' => 1, 'created_by' => 2];
$pages = Page::filter($parameters)->orderBy('title', 'asc')->paginate();
```

Taking parameters directly from the URL

```
$pages = Page::filter($request->all())->orderBy('title', 'asc')->paginate();
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

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

---

Top Contributors

[![DanSmith83](https://avatars.githubusercontent.com/u/6223397?v=4)](https://github.com/DanSmith83 "DanSmith83 (5 commits)")

### Embed Badge

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

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

PHPackages © 2026

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