Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Filtering Laravel Package

indexzer0/eloquent-filtering

Filter Laravel Eloquent models using simple arrays and request data—no custom query spaghetti. Define allowed filters on your models, support complex search, and keep queries readable, maintainable, and easy to extend for APIs and dashboards.

View on GitHub
Deep Wiki
Context7

Filter example

Latest Version on Packagist Total Downloads GitHub Tests Action Status Codecov


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.


View The Docs


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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport