Nova filter that displays a Date Range Picker instead of a select. This field also supports dark-mode, Nova 4 and Nova 5.
Run this command in your nova project:
composer require marshmallow/nova-date-range-filter
Add the DateRangeFilter to your resource filters array.
public function filters(Request $request)
{
return [
new \Marshmallow\Filters\DateRangeFilter('created_at', 'Created date'),
];
}
With this method, you can set default date ranges that you use frequently. For instance ranges like today, yesterday, this month etc. Please check the example below.
(new DateRangeFilter('created_at', 'Created date'))
->addRange('Today', now()->startOfDay(), now()->endOfDay())
->addRange('Yesterday', now()->subDay()->startOfDay(), now()->subDay()->endOfDay())
->addRange('This week', now()->startOfWeek(), now()->endOfWeek())
->addRange('Last 7 days', now()->subDays(7)->startOfDay(), now()->endOfDay())
->addRange('Last 30 days', now()->subDays(30)->startOfDay(), now()->endOfDay())
->addRange('This month', now()->startOfMonth(), now()->endOfMonth())
->addRange('Last month', now()->startOfMonth()->subMonth(1), now()->startOfMonth()->subMonth(1)->endOfMonth())
->addRange('This year', now()->startOfYear(), now()->endOfYear()),
With this method, it will be possible to show more then just the current month.
Enable the time selector when you select your date.
Set a min time that can be selected.
Set a max time that can be selected.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.