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

Product Decisions This Supports

  • API Search/Filtering: Accelerate development of scalable, dynamic filtering for RESTful APIs (e.g., e-commerce product listings, admin dashboards).
  • Roadmap: Prioritize reusable query logic over custom solutions, reducing tech debt for future feature expansion (e.g., adding complex filters like $jsonLength).
  • Build vs. Buy: Avoid reinventing query-building wheels; leverage this package to standardize filtering across Laravel models, saving ~30% dev time.
  • Use Cases:
    • Public APIs: Client-driven filtering (e.g., ?name=$eq:TV&price=$gt:100).
    • Admin Panels: Role-based filtering (e.g., ?status=$eq:active&user_id=$eq:123).
    • Legacy Migration: Modernize monolithic queries into declarative model methods.

When to Consider This Package

  • Adopt if:
    • Your Laravel app (v10+) uses Eloquent and requires dynamic, HTTP-driven filtering (e.g., API endpoints).
    • You need consistent, maintainable query logic across 5+ models (e.g., User, Product, Order).
    • Your team prioritizes developer velocity over custom SQL/Query Builder logic.
    • You support JSON fields (e.g., options->languages) or complex conditions ($or, $and).
  • Look elsewhere if:
    • You’re using non-Eloquent ORMs (e.g., Doctrine, MongoDB).
    • Your filtering needs are static (e.g., hardcoded queries in a single controller).
    • You require advanced sorting (package notes this is "in its infancy").
    • Your PHP version is <8.2 or Laravel <10.

How to Pitch It (Stakeholders)

For Executives: "Eloquent Filtering lets us ship search/filter features 3x faster by standardizing how our APIs handle client-driven queries. For example, a product team can now add filters like price=$gt:100 without backend dev cycles. It’s MIT-licensed, battle-tested (225 stars), and reduces technical debt by centralizing query logic in models—not controllers. ROI: Faster feature delivery, fewer bugs in ad-hoc queries."

For Engineering: *"This package replaces repetitive where() chains with declarative model methods. For instance:

// Before: Manual query logic
$products = Product::query()
    ->where('name', 'like', '%TV%')
    ->where('price', '>', 100)
    ->get();

// After: Clean, reusable filters
class Product extends Model {
    use Filterable;
    public function allowedFilters() { ... }
}
$products = Product::filter([['type' => '$like', 'target' => 'name', 'value' => 'TV']])->get();

Key benefits:

  • Type safety: Enforce allowed filters per model (e.g., block price=$lt:0).
  • HTTP-friendly: Directly parse ?name=$like:TV into queries.
  • Extensible: Add filters like $jsonLength for nested data without SQL hacks. Tradeoff: Sorting is immature (avoid for now), but core filtering is production-ready."*
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.
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
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope