jurager/filterable
Composer 安装命令:
composer require jurager/filterable
包简介
Laravel package for building complex eloquent filters in a simple, structured way
README 文档
README
A Laravel package that adds JSON:API-compatible filter and sort query parameter support to Eloquent models.
Features:
- Declarative
$filterableand$sortablearrays on the model — no boilerplate controllers - Full operator set:
eq,ne,gt,gte,lt,lte,like,in,nin,null,not_null,between,not_between,tree - Relation filtering via
whereHassubqueries and pivot column support - Filtered eager-loading with
filter[included.*] - OR / AND condition groups
- Field, relation, and sort resolver interfaces for custom SQL
- Full-result caching (Redis / Memcached) with automatic tag-based invalidation
- Entity-Attribute-Value attribute filtering via
jurager/eavresolver - NestedSet descendant expansion via the
treeoperator
Requirements
- PHP 8.2+
- Laravel 11+
Installation
composer require jurager/filterable
Add HasFilterable to your model and declare allowed fields:
use Jurager\Filterable\Concerns\HasFilterable; class Product extends Model { use HasFilterable; protected array $filterable = [ 'sku' => ['eq', 'like'], 'price' => ['gte', 'lte', 'between'], 'status' => ['eq', 'in'], 'category.name' => ['eq', 'like'], 'is_active', ]; protected array $sortable = ['id', 'sku', 'price', 'created_at']; }
Apply in the controller:
Product::query()->filter()->sort()->paginate();
Request:
GET /products?filter[status][in][]=active&filter[price][gte]=100&sort=-created_at
Documentation
To learn more about filtering, sorting, relations, caching, and advanced usage please go to the Documentation.
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-25