indexzer0 / eloquent-filtering
强大的eloquent过滤功能
2.1.0
2024-09-28 20:57 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^2.9
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^3.0.0
- pestphp/pest-plugin-arch: ^3.0.0
- pestphp/pest-plugin-laravel: ^3.0.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^1.1
- phpstan/phpstan-phpunit: ^1.3
- spatie/laravel-ray: ^1.35
This package is auto-updated.
Last update: 2024-09-28 23:38:53 UTC
README
使用数组轻松过滤eloquent模型
Eloquent Filtering 简化了实现Eloquent模型(无论简单还是复杂)的搜索功能,通过消除自定义查询逻辑的需求。它允许您轻松在模型中定义和管理过滤器,并无缝地使用传入的HTTP请求数据动态过滤模型。
使用此包,您可以构建更易读、可维护和可扩展的代码,提高您的生产力和加快开发速度。
无论您是在构建API、仪表板还是高级搜索系统,Eloquent Filtering提供了一种强大且灵活的方法来简化Eloquent查询,使管理并扩展应用程序的过滤功能变得更加容易。
查看文档
快速预览
class Product extends Model implements IsFilterable { use Filterable; public function allowedFilters(): AllowedFilterList { return Filter::only( Filter::field('name', [FilterType::EQUAL]), ); } } $products = Product::filter([ [ 'target' => 'name', 'type' => '$eq', 'value' => 'TV' ] ])->get();
需求
- PHP版本 >=
8.2
- Laravel版本 >=
10
安装
您可以通过composer安装此包
composer require indexzer0/eloquent-filtering
运行install
artisan命令以发布配置
php artisan eloquent-filtering:install
测试
composer test
文档
npm i -g mintlify
cd docs
mintlify dev
变更日志
请参阅变更日志以获取有关最近更改的更多信息。
功能想法
请参阅功能想法以获取潜在的未来功能。
鸣谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。