PHP MIT

eloquent-filtering

Easily filter eloquent models using arrays - great for filtering from http requests

I

IndexZer0

Dernière activité 22 juin 2026
IndexZer0/eloquent-filtering

224

étoiles

8

forks

3

issues ouvertes

Ce README est souvent en anglais.

Eloquent Filtering

Filter example

Latest Version on Packagist Total Downloads GitHub Tests Action Status Codecov


Easily filter eloquent models using arrays

Eloquent Filtering simplifies implementing search functionality for your Eloquent models, whether simple or complex, by eliminating the need for custom query logic. It allows you to easily define and manage filters directly within your models, and seamlessly apply them using incoming HTTP request data to dynamically filter your models.

With this package, you can build more readable, maintainable, and scalable code, boosting your productivity and speeding up development.

Whether you’re building APIs, dashboards, or advanced search systems, Eloquent Filtering provides a powerful and flexible way to streamline your Eloquent queries, making it easier to manage and extend your application’s filtering capabilities.



Quick Look

class Product extends Model implements IsFilterable
{
    use Filterable;

    public function allowedFilters(): AllowedFilterList
    {
        return Filter::only(
            Filter::field('name', [FilterType::EQUAL]),
        );
    }
}

$products = Product::filter([
    [
        'target' => 'name',
        'type'   => '$eq',
        'value'  => 'TV'
    ]
])->get();

Requirements

  • PHP Version >= 8.2
  • Laravel Version >= 10

Installation

You can install the package via composer:

composer require indexzer0/eloquent-filtering

Run the install artisan command to publish the config:

php artisan eloquent-filtering:install

Testing

composer test

Docs

npm i -g mintlify
cd docs
mintlify dev

Changelog

Please see CHANGELOG for more information on what has changed recently.


Feature Ideas

Please see Feature ideas for potential future features.


Credits


License

The MIT License (MIT). Please see License File for more information.

Projets similaires

Offers an simple way to filter and search eloquent models by array parameters and query strings

PHPeloquentfilterlaravel
Llacodix
176 étoiles14

An Eloquent Way To Filter Laravel Models And Their Relationships

PHPdynamic-filterseloquenteloquent-filters
TTucker-Eric
1,8 k étoiles125

Eloquent Filter is a package for filter data of models by the query strings. Easy to use and fully dynamic.

PHPconditions-eloquent-filterdynamic-filterseloquent
Mmehdi-fathi
447 étoiles41