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

Define allowed filters on your Eloquent models and apply them from simple arrays or request data—no custom query logic. Supports complex, type-based filtering for APIs and dashboards on Laravel 10+ / PHP 8.2+.

View on GitHub
Deep Wiki
Context7

title: 'Validation Rules' version: 'v2' icon: 'shield-check' iconType: 'solid'

Overview

You can define your own validation rules, messages, and attributes for any AllowedType.

  • When a filter does not pass validation rules, a MalformedFilterFormatException is thrown.
  • MalformedFilterFormatException extends Laravels ValidationException.
    • You can let this bubble up to your controller for the default laravel 422 response.
  • This exception CAN be suppressed.
class Order extends Model implements IsFilterable
{
    use Filterable;

    public function allowedFilters(): AllowedFilterList
    {
        return Filter::only(
            Filter::field('status', [
                FilterType::EQUAL->withValidation([
                    'value' => [Rule::enum(OrderStatus::class)],
                ], [
                    'enum' => 'The selected :attribute is invalid.',
                ], [
                    'value' => 'status value',
                ]),
                FilterType::IN->withValidation([
                    'value.*' => [Rule::enum(OrderStatus::class)]
                ])
            ]),
            Filter::field('paid_date', [
                FilterType::BETWEEN->withValidation([
                    'value.0' => ['date', 'before:value.1'],
                    'value.1' => ['date', 'after:value.0'],
                ])
            ]),
            Filter::field('created_at', [
                new AllowedType('$yourCustomFilterType')->withValidation([
                    'value' => [new YourCustomRule()],
                ])
            ]),
        );
    }
}
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.
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle