催化社 / laravel-filterable
用于 Laravel 的简单过滤器库
v1.0.1
2020-09-22 23:45 UTC
Requires
- php: ^7.2
- illuminate/database: ^6.18.31|^7.22.4
- illuminate/http: ^6.18.31|^7.22.4
- illuminate/pipeline: ^5.5|^6.0|^7.0
- illuminate/support: ^6.0|^7.0
This package is not auto-updated.
Last update: 2024-09-20 05:59:16 UTC
README
此包允许您通过查询字符串轻松处理数据库过滤。
安装
您可以通过 composer 安装此包
对于 Laravel 6.x & 7.x
composer require catalyzecomm/laravel-filterable
简介
简介内容
用法
定义您的模型(使用 Catalyzecomm\Filterable 特性和定义 $allowedFilters)
use Catalyzecomm\Filterable; ... /** * Define an array of filter that allowed to use for this model * `key` as class name and `value` as field name(s) * * @var array */ protected static $allowedFilters = [ Catalyzecomm\Filters\Sort::class => 'created_at', Catalyzecomm\Filters\Keywords::class => 'name,email', ];
在控制器中使用
$users = User::filterPaginate();
或
$users = User::filterAll();
鸣谢
许可证
MIT 许可证(MIT)。请参阅 许可证文件 获取更多信息。