PHPackages                             mostafarabia/easy-filters - 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. [Search &amp; Filtering](/categories/search)
4. /
5. mostafarabia/easy-filters

ActiveLibrary[Search &amp; Filtering](/categories/search)

mostafarabia/easy-filters
=========================

This is my package easy-filters

v1.0.3(5mo ago)05MITPHPPHP ^7.4|^8.0CI passing

Since Nov 23Pushed 5mo agoCompare

[ Source](https://github.com/MostafaRabia/easy-filters)[ Packagist](https://packagist.org/packages/mostafarabia/easy-filters)[ Docs](https://github.com/mostafarabia/easy-filters)[ GitHub Sponsors](https://github.com/MRabia)[ RSS](/packages/mostafarabia-easy-filters/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (11)Versions (3)Used By (0)

EasyFilters
===========

[](#easyfilters)

**EasyFilters** is a powerful, flexible, and lightweight Laravel package that simplifies filtering and searching in your Eloquent models. It allows you to filter by columns, relationships, and custom logic using query parameters, all with a clean and fluent API.

Features
--------

[](#features)

- **Easy Filtering**: Filter by any column using `easyFilters()`.
- **Advanced Logic**: Support for `AND` and `OR` logic in filters.
- **Global Search**: Search across multiple columns and relationships with `easySearch()`.
- **Flexible Range Filtering**: Built-in support for `min`, `max`, `start`, and `end` range filters.
- **Relationship Support**: Filter and search deep into relationships using dot notation (e.g., `posts.comments.title`).
- **Customizable**: Control allowed filters, custom filter classes, and request keys.
- **Auto-Resolution**: Automatically resolves filter types (Like, Where, WhereIn, WhereRange) based on input.

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

[](#installation)

You can install the package via composer:

```
composer require mostafarabia/easy-filters
```

You can publish the config file with:

```
php artisan vendor:publish --tag="easy-filters-config"
```

Usage
-----

[](#usage)

### 1. Filtering (`EasyFilterable`)

[](#1-filtering-easyfilterable)

Add the `EasyFilterable` trait to your model:

```
use MRabia\EasyFilters\Traits\EasyFilterable;

class User extends Model
{
    use EasyFilterable;

    // Optional: Restrict allowed filters
    public $allowedFilters = ['name', 'status', 'created_at', 'posts.title'];

    // Optional: Map columns to specific filter classes
    public $filterMapping = [
        'status' => \MRabia\EasyFilters\Filters\Where::class,
    ];
}
```

#### Basic Filtering (AND Logic)

[](#basic-filtering-and-logic)

By default, filters passed in the `filters` key are combined using `AND`.

```
// GET /users?filters[status]=active&filters[name]=John
User::easyFilters()->get();
// Result: WHERE status = 'active' AND name LIKE '%John%'
```

#### Optional Filtering (OR Logic)

[](#optional-filtering-or-logic)

Filters passed in the `optional_filters` key are combined using `OR` (grouped).

```
// GET /users?filters[status]=active&optional_filters[role]=admin&optional_filters[role]=editor
User::easyFilters()->get();
// Result: WHERE status = 'active' AND (role = 'admin' OR role = 'editor')
```

#### Range Filtering

[](#range-filtering)

The package automatically detects range queries if you use `min`/`max` or `start`/`end` keys.

```
// GET /users?filters[price][min]=100&filters[price][max]=500
// GET /users?filters[created_at][start]=2023-01-01
User::easyFilters()->get();
```

### 2. Global Search (`EasySearchable`)

[](#2-global-search-easysearchable)

Add the `EasySearchable` trait to your model to enable global search across multiple columns.

```
use MRabia\EasyFilters\Traits\EasySearchable;

class User extends Model
{
    use EasySearchable;

    // Required: Define searchable columns
    public $allowedSearch = ['name', 'email', 'posts.title'];
}
```

```
// GET /users?search=John
User::easySearch()->get();
// Result: WHERE (name LIKE '%John%' OR email LIKE '%John%' OR posts.title LIKE '%John%')
```

Configuration
-------------

[](#configuration)

You can customize the request keys in `config/easyfilters.php`:

```
return [
    'filters_key' => 'filters',
    'optional_filters_key' => 'optional_filters',
    'search_key' => 'search',
    'default_column_to_use_like' => ['name'], // Columns that use LIKE instead of WHERE
];
```

You can customize which columns automatically use the `LIKE` filter. By default, any column named `name` will use `LIKE` for partial matching. Add more columns to the array as needed:

```
'default_column_to_use_like' => ['name', 'title', 'description'],
```

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance71

Regular maintenance activity

Popularity4

Limited adoption so far

Community6

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.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

166d ago

PHP version history (2 changes)v1.0.0PHP ^8.3

v1.0.3PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5bac6341353553ca4a16d4424c8bf1578712fc44b50e7ccd7bea63a6cf152261?d=identicon)[MostafaRabia](/maintainers/MostafaRabia)

---

Top Contributors

[![MostafaRabia](https://avatars.githubusercontent.com/u/25965798?v=4)](https://github.com/MostafaRabia "MostafaRabia (1 commits)")

---

Tags

laravelMRabiaeasy-filters

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/mostafarabia-easy-filters/health.svg)

```
[![Health](https://phpackages.com/badges/mostafarabia-easy-filters/health.svg)](https://phpackages.com/packages/mostafarabia-easy-filters)
```

###  Alternatives

[spatie/laravel-site-search

A site search engine

300129.1k](/packages/spatie-laravel-site-search)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[codewithdennis/filament-price-filter

A simple and customizable price filter for FilamentPHP, allowing users to easily refine results based on specified price ranges.

163.2k](/packages/codewithdennis-filament-price-filter)[eightynine/filament-docs

Elegant documentation system for your Filament application with search, navigation, and markdown support

122.5k1](/packages/eightynine-filament-docs)

PHPackages © 2026

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