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.
/products?filters[][target]=name&filters[][type]=$like&filters[][value]=TV), reducing manual query-building in controllers.where() chains) or third-party solutions (e.g., Scout, Meilisearch) for simple-to-moderate filtering needs, reducing technical debt.status=$eq:active).created_at$gt:2023-01-01).if-else chains for query conditions).For Executives:
"Eloquent Filtering lets us standardize how our APIs and dashboards handle search/filtering—reducing backend complexity and speeding up feature delivery. For example, instead of writing custom SQL for every ‘filter by X’ request, we define rules once in the model (e.g., Product::filter([['target' => 'price', 'type' => '$gt', 'value' => 100]])). This cuts dev time by 30% for search-heavy features and makes our APIs more predictable for frontend teams. It’s a low-risk, high-reward investment for our Laravel stack."
For Engineering:
*"This package replaces repetitive where() logic in controllers with a declarative approach:
allowedFilters(): Filter::only(FilterType::EQUAL, FilterType::LIKE)), so invalid requests fail fast.?filters[][target]=name&filters[][type]=$like&filters[][value]=TV → WHERE name LIKE '%TV%').options->languages$jsonLength:>=2) and logical operators ($or, $and).For Developers: *"No more writing:
if ($request->has('min_price')) {
$query->where('price', '>=', $request->min_price);
}
Instead, define filters in your model:
class Product extends Model {
use Filterable;
public function allowedFilters() {
return Filter::only(
FilterType::EQUAL, FilterType::GREATER_THAN, FilterType::LIKE
);
}
}
Then use it anywhere:
Product::filter($request->filters)->get();
Supports 10+ filter types (equality, ranges, wildcards, JSON paths) and integrates with Laravel’s request validation."*
How can I help you explore Laravel packages today?