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

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

achillesp/laravel-filterable
============================

Filter eloquent models in Laravel.

1.0(8y ago)1413MITPHPPHP ^7.0

Since Oct 31Pushed 8y ago1 watchersCompare

[ Source](https://github.com/achillesp/laravel-filterable)[ Packagist](https://packagist.org/packages/achillesp/laravel-filterable)[ RSS](/packages/achillesp-laravel-filterable/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Filter Laravel Models
=====================

[](#filter-laravel-models)

This Laravel package provides an abstraction for filtering Eloquent Models based on a request.

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

[](#installation)

From the command line, run:

```
composer require achillesp/laravel-filterable

```

Usage
-----

[](#usage)

To be able to filter a model, you need to use the trait Filterable.

```
use Achillesp\Filterable\Filterable;

class Post extends Eloquent
{
    use Filterable;
}
```

The filters are defined in their own class, which extends the class Achillesp\\Filterable\\Filters. In this class you need to provide a `$filters` array which contains the names of the filters you'd like to use. You then declare a method for each of those filters, that queries the model accordingly. You could use the same filter class for more than one model, or have a different filter class for each model you want to filter.

```
use Achillesp\Filterable\Filters;

class PostFilters extends Filters
{
    protected $filters = ['category', 'published'];

    protected function category(int $categoryId)
    {
        return $this->builder->where('category_id', $categoryId);
    }

    protected function published(bool $isPublished)
    {
        return $this->builder->where('is_published', $isPublished);
    }
}
```

You can then filter the model either directly from a request or by giving an array of key-value pais.

To filter based on a request, for example in a controller:

```
public function search(Request $request)
{
    $filters = new PostFilters($request);
    $posts = Post::filter($filters)->get();
    return $posts;
}
```

Or to filter based on an array:

```
$filters = new PostFilters(['category' => 1, 'published' => true]);
$posts = Post::filter($filters)->get();
```

License
-------

[](#license)

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

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

3115d ago

### Community

Maintainers

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

---

Top Contributors

[![achillesp](https://avatars.githubusercontent.com/u/5294270?v=4)](https://github.com/achillesp "achillesp (7 commits)")

---

Tags

eloquentfilterlaravellaravel-5-packagelaraveleloquentfilter

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[lacodix/laravel-model-filter

A Laravel package to filter, search and sort models with ease while fetching from database.

17649.9k](/packages/lacodix-laravel-model-filter)[indexzer0/eloquent-filtering

Powerful eloquent filtering

22425.9k3](/packages/indexzer0-eloquent-filtering)[czim/laravel-filter

Filter for Laravel Eloquent queries, with support for modular filter building

8973.0k3](/packages/czim-laravel-filter)[mnabialek/laravel-eloquent-filter

Allows filtering Eloquent queries by input filters

2614.5k](/packages/mnabialek-laravel-eloquent-filter)[omalizadeh/laravel-query-filter

A laravel package for resource filtering via request query string

163.0k](/packages/omalizadeh-laravel-query-filter)[matthenning/eloquent-api-filter

Awesome and simple way to filter Eloquent queries right from the API URL without the clutter.

104.9k](/packages/matthenning-eloquent-api-filter)

PHPackages © 2026

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