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+.
$jsonLength).?name=$eq:TV&price=$gt:100).?status=$eq:active&user_id=$eq:123).User, Product, Order).options->languages) or complex conditions ($or, $and).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:
price=$lt:0).?name=$like:TV into queries.$jsonLength for nested data without SQL hacks.
Tradeoff: Sorting is immature (avoid for now), but core filtering is production-ready."*How can I help you explore Laravel packages today?