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+.
Pros:
FilterType enums, reducing runtime errors.Cons:
with() or load().$jsonLength) could impact query performance on large datasets.Filter::field()) could expose vulnerabilities.allowedFilters() must be carefully configured to avoid exposing sensitive fields.$or/$and conditions may not behave as expected without thorough testing.where() clauses, custom query scopes).Product or User) to test integration.Filterable trait.$eq, $like) for high-impact endpoints.$jsonLength, $or/$and) for advanced use cases.FilterType), but may require PHP upgrades.$jsonLength).allowedFilters() doesn’t expose sensitive fields in serialized responses.php artisan eloquent-filtering:install).$like).use Filterable; and define allowedFilters() in target models.$eq, $gt) before complex ones.Model::filter().$filters = request()->input('filters', []);
$results = Product::filter($filters)->get();
$eq vs. $like syntax).where() clauses in controllers.allowedFilters()) serve as API documentation.indexzer0/eloquent-filtering could require updates.target fields).cursor() for pagination with filtered queries.name, price).$or/$and conditions, which can bloat SQL.try-catch or validate input early.Filter::field() with nullable defaults or fallback logic.Model::filter() in transactions for critical operations.request()->input('filters') to prevent deep nesting attacks.allowedFilters() doesn’t expose sensitive fields (e.g., password).$model->fresh()) if filters affect concurrent writes.Filterable trait and allowedFilters() syntax.where() clauses to the package.$like:start).How can I help you explore Laravel packages today?