-
Notifications
You must be signed in to change notification settings - Fork 92
Description
Currently, the DateRangePreset enum includes 18 presets covering past dates (Yesterday, Last 7 Days, Last Month, etc.) and present (Today), but there's no built-in preset for "Tomorrow".
This creates an asymmetry in the available options. While past-focused presets are useful for reporting and analytics, scheduling-focused applications often need a quick way to select tomorrow's date.
Use case
In scheduling/booking systems, users frequently need to filter or select appointments for tomorrow. Currently, implementing this requires:
- Publishing the date-picker view
- Adding custom JavaScript to handle the preset
- Manually dispatching events to sync with Livewire
- Ensuring the correct data format (
{start, end}object) is passed toDateRange
This is surprisingly complex for such a common use case.
Proposed solution
Add Tomorrow to the DateRangePreset enum:
case Tomorrow = 'tomorrow';
public function dates(): array
{
return match ($this) {
// ...existing cases
self::Tomorrow => [Carbon::tomorrow(), Carbon::tomorrow()],
};
}
public function label(): string
{
return match ($this) {
// ...existing cases
self::Tomorrow => __('Tomorrow'),
};
}And add the corresponding static method to DateRange:
public static function tomorrow() {
return static::fromPreset(DateRangePreset::Tomorrow);
}This would allow users to simply add tomorrow to their presets string:
<flux:date-picker presets="today tomorrow yesterday thisWeek" />Thank you for considering this enhancement!