marshmallow/nova-date-range-field is a Laravel package for a laravel nova field..
It currently has 3 GitHub stars and 10.483 downloads on Packagist (latest version 5.0.0).
Install it with composer require marshmallow/nova-date-range-field.
Discover more Laravel packages by marshmallow
or browse all Laravel packages to compare alternatives.
Last updated

A Laravel Nova field that provides a date range picker (powered by flatpickr). It can store a range across two model attributes (a "from" and a "till"), as a single value, or as JSON.
Install the package via Composer in your Nova project:
composer require marshmallow/nova-date-range-field
The field's assets are registered automatically through Marshmallow\NovaDateRangeField\FieldServiceProvider (Laravel package auto-discovery), so there is nothing else to publish or configure.
Use the DateRange field on a Nova resource and define the names of the from and till attributes together with the label. If no fields are set, the string value is stored in the database column of the field's attribute.
use Marshmallow\NovaDateRangeField\DateRange;
public function fields(Request $request)
{
return [
DateRange::make(__('Access Date'), ['from', 'till']),
// OR
DateRange::make(__('Access Date'))
->fields('from', 'till'),
];
}
Additional flatpickr options can be passed through the options array. These overwrite the field's default options (weekNumbers, defaultHour, defaultMinute).
DateRange::make(__('Date range'))
->fields('from', 'till')
->options([
'defaultHour' => 0,
'defaultMinute' => 0,
]),
The available chainable options (with their default behaviour) are:
->modeType('range') // Set the picker mode ('range' or 'single')
->range() // Range mode (default)
->single() // Single date mode
->twelveHourTime() // Twelve hour time display
->enableSeconds() // Enable seconds in the time picker
->separator('-') // Separator shown between the from/till values
->firstDayOfWeek(1) // First day of the week
->enableTime() // Enable the time picker
->dateFormat('Y-m-d') // flatpickr date format
->placeholder('date range')
->saveAsJSON() // Store the value as JSON instead of separate columns
When saveAsJSON() is used (or when the field's attribute is cast to array on the model), the range is stored as JSON on a single attribute instead of being split across the from and till columns.
Please report security vulnerabilities by email rather than via the public issue tracker.
The MIT License (MIT). Please see the License File for more information.