PHPackages                             emmadonjo/laravel-filter - 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. emmadonjo/laravel-filter

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

emmadonjo/laravel-filter
========================

A laravel package to easily add filtering to your eloquent queries

v1.0.0(4mo ago)2545MITPHPPHP &gt;=8CI failing

Since Sep 18Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/emmadonjo/laravel-filter)[ Packagist](https://packagist.org/packages/emmadonjo/laravel-filter)[ RSS](/packages/emmadonjo-laravel-filter/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

[![Build Status](https://github.com/emmadonjo/laravel-filter/actions/workflows/tests.yml/badge.svg)](https://github.com/emmadonjo/laravel-filter/actions)[![Total Downloads](https://camo.githubusercontent.com/9e891921d4e5a42f06df331613fc26d5ed1b5413cf92afc2689bff76f4ca44c0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656d6d61646f6e6a6f2f6c61726176656c2d66696c746572)](https://packagist.org/packages/emmadonjo/laravel-filter)[![Latest Stable Version](https://camo.githubusercontent.com/543cb6cdc2c4dd0f55a6a058aa46cb068621af3959bfd8c5bf3dd6f4499b5ca9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d6d61646f6e6a6f2f6c61726176656c2d66696c746572)](https://packagist.org/packages/emmadonjo/laravel-filter)[![License](https://camo.githubusercontent.com/93967bc8e0049d67400f44b5ea9c832a646abb5ee334b8627a503ee1605a1739/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656d6d61646f6e6a6f2f6c61726176656c2d66696c746572)](https://packagist.org/packages/emmadonjo/laravel-filter)

Laravel Filter is a laravel package to easily add filtering and search capabilities to your eloquent queries.

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

[](#installation)

Install via composer:

```
    composer require emmadonjo/laravel-filter
```

Usage
-----

[](#usage)

### Filtering

[](#filtering)

You can:

- Filter single or multiple columns
- Filter columns with list (array) of possible values

To filter,

- use the `HasFilter` trait
- define a `filterableColumns()` method that returns an array of columns that can be filtered
- optionally, implement `Filterable` interface
- in your queries, use the `filter($filters)` method to filter records

```
    ...

    use Emmadonjo\LaravelFilter\Contracts\Filterable;
    use Emmadonjo\LaravelFilter\Concerns\HasFilter;

    class Post extends Model implements Filterable
    {
        use HasFilter;

        public function filterableColumns(): array
        {
            return [
                'slug',
                'author_id',
                'status'
            ];
        }
    }

    // filter posts
    $filters = ['author_id' => 1, 'status' => 'published'];

    Post::filter($filters)->get();

    // filter a post's column with multiple possible values
    $filters = ['status' => ['scheduled', 'draft']];

    Post::filter($filters)->get();

    // combine both
    $filters = [
        'status' => ['scheduled', 'draft'],
        'author_id' => 1
    ];

    Post::filter($filters)->get();
```

### Searching

[](#searching)

To search,

- use the `HasSearch` trait
- define a `searchableColumns()` method that returns an array of columns that can be searched
- optionally, implement `Searchble` interface
- in your queries, use the `search($searchTerm)` method to search records

**Performance**

- For large records or columns with large values, it's advisable to use a service/package that supports fulltext search, for example, Elasticsearch.
- Indexing searching columns (where necessary) will help improve performance, but this should be carefully done.

```
    ...

    use Emmadonjo\LaravelFilter\Contracts\Searchable;
    use Emmadonjo\LaravelFilter\Concerns\HasSearch;

    class Post extends Model implements Searchable
    {
        use HasSearch;

        public function searchableColumns(): array
        {
            return [
                'slug',
                'content',
            ];
        }
    }

    $searchTerm = "hello"

    Post::search($searchTerm)->get();
```

### Filtering and Searching

[](#filtering-and-searching)

To filter &amp; search,

- use the `HasFilter` and `HasSearch` traits
- define a `filterableColumns()` and `searchableColumns` methods that return arrays of columns that can be filtered or searched respectively
- optionally, implement `Filterable` and, or `Searchable` interfaces
- in your queries, use the `filter($filters)` and `search($searchTerm)` methods to filter and search records

```
    ...

    use Emmadonjo\LaravelFilter\Contracts\Filterable;
    use Emmadonjo\LaravelFilter\Contracts\Searchable
    use Emmadonjo\LaravelFilter\Concerns\HasFilter;
    use Emmadonjo\LaravelFilter\Concerns\HasSearch;

    class Post extends Model implements Filterable, Searchable
    {
        use HasFilter;
        use HasSearch

        public function filterableColumns(): array
        {
            return [
                'slug',
                'author_id',
                'status',
            ];
        }

        public function searchableColumns() : array
        {
             return [
                 'title',
                 'content',
            ]
        }
    }

    $filters = ['author_id' => 1, 'status' => 'published'];

    Post::filter($filters)
        ->search("hello")
        ->get();

    // filter a post's column with multiple possible values while applying search
    $filters = ['status' => ['scheduled', 'draft']];

    Post::search('hello')
        ->filter($filters)
        ->get();
```

Changelog
---------

[](#changelog)

Kindly see the [releases](https://github.com/emmadonjo/laravel-filter/releases) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Pull requests are highly welcomed. Ensure you follow the PSR coding standards and meet static analysis level of 9.

License
-------

[](#license)

The MIT License (MIT). Please see [LICENSE](https://github.com/emmadonjo/laravel-filter/blob/master/LICENSE.md) for details.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance75

Regular maintenance activity

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Every ~170 days

Total

4

Last Release

136d ago

Major Versions

v0.0.3 → v1.0.02026-02-09

### Community

Maintainers

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

---

Top Contributors

[![emmadonjo](https://avatars.githubusercontent.com/u/22492808?v=4)](https://github.com/emmadonjo "emmadonjo (18 commits)")

---

Tags

eloquentlaravelphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/emmadonjo-laravel-filter/health.svg)

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

###  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)

PHPackages © 2026

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