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. [Database &amp; ORM](/categories/database)
4. /
5. dansmith/eloquent-filterable

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

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 4w 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 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

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://avatars.githubusercontent.com/u/174349?v=4)[Dan](/maintainers/dansmith)[@DanSmith](https://github.com/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)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

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