rpj/daterangepicker
Composer 安装命令:
composer require rpj/daterangepicker
包简介
A simple Date Range filter for Laravel Nova 4.
关键字:
README 文档
README
A filter for Nova 4 that displays a Date Range Picker instead of a single date picker using Daterangepicker library
Install
Run this command in your nova project:
composer require rpj/daterangepicker
How to use
In your Nova resource, just add DateRangeFilter class in the filters function, and include the column(s) that you would like to use as filter the resource.
use Rpj\Daterangepicker\Daterangepicker; public function filters(Request $request) { return [ new Daterangepicker('created_at'), ]; }
Column name can be a string or an array of strings with two items. Otherwise an exception will be fired.
use Rpj\Daterangepicker\Daterangepicker; public function filters(Request $request) { return [ new Daterangepicker(['created_at', 'updated_at']), ]; }
Also, you can pass a string with default date range to use in the component. If no value is passed, TODAY value is set as default, but if you want to remove the date filter to show all records, you can use DateHelper::ALL
Additionally, we added a custom date range picker that allows user to specify the column to order by with its value and as well as in the case of a joined table to prevent ambiguous mysql error, you can specify the actual table name to know the actual column you are referring to. this takes, the column to check the date range picker and as well as the column to order by with the asc/desc direction.
use Rpj\Daterangepicker\Daterangepicker; use Rpj\Daterangepicker\DateHelper; public function filters(Request $request) { return [ new Daterangepicker('users.created_at', DateHelper::THIS_WEEK, 'users.name', 'desc'), ]; }
Finally, we have added the option to set a custom pre set dates using Carbon class. Also you can set a min and max date for the date range component.
use Rpj\Daterangepicker\Daterangepicker; use Rpj\Daterangepicker\DateHelper; use Carbon\Carbon; public function filters(Request $request) { return [ (new Daterangepicker( 'users.created_at', DateHelper::THIS_WEEK, 'users.name', 'desc' )) ->setRanges([ 'Today' => [Carbon::today(), Carbon::today()], 'Yesterday' => [Carbon::yesterday(), Carbon::yesterday()], 'This week' => [Carbon::now()->startOfWeek(), Carbon::now()->endOfWeek()], 'This month' => [Carbon::now()->startOfMonth(), Carbon::now()->endOfMonth()], 'Last month' => [Carbon::now()->subMonth()->startOfMonth(),Carbon::now()->subMonth()->endOfMonth()], ]) ->setMaxDate(Carbon::today()) ->setMinDate(Carbon::today()->endOfYear()), ]; }
rpj/daterangepicker 适用场景与选型建议
rpj/daterangepicker 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 85.49k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2023 年 12 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「date」 「filter」 「nova」 「daterange」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rpj/daterangepicker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rpj/daterangepicker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rpj/daterangepicker 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova card that shows you your system information.
A Laravel Nova card.
Tools to convert between .NET and PHP date formats
Nova searchable filter for belongsTo relationships.
A Laravel Nova package for publishable fields
A Laravel Nova package for translatable fields
统计信息
- 总下载量: 85.49k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-12-12