michielfb / laravel-nova-time-field
A HTML5 time field for Laravel Nova.
Installs: 278 769
Dependents: 0
Suggesters: 0
Security: 0
Stars: 20
Watchers: 2
Forks: 4
Open Issues: 0
Requires
- php: ^7.3|^8.0
- laravel/nova: ^4.0|^5.0
Requires (Dev)
- phpunit/phpunit: ^9.5.10
This package is auto-updated.
Last update: 2025-01-18 16:33:17 UTC
README
This package adds a basic HTML5 time field to Laravel Nova.
Requirements
This package require laravel/nova:~4.0.
Installation
Use composer to install the package.
composer require michielfb/laravel-nova-time-field
Usage
The example below shows how to create a Time field where users can enter hours, minutes, and seconds. The time is show in the "h:i A" format (For example 11:15 PM). When no value is entered the value "n/a" is shown.
use Michielfb\Time\Time; Time::make('Time') ->withSeconds() ->format('h:i A', 'n/a');
For documentation on how to add fields to a resource see the Laravel Nova documentation.
Format
Use the format
method to customize how to date is shown to users. The format must be a
PHP date format.
A default value can be passed to the format
method. This determines the value shown to users if there is no
value entered.
use Michielfb\Time\Time; Time::make('Time') ->format('h:i A', '-');
Steps
The step attribute
can be configured by using the withSteps
method.
<?php use Michielfb\Time\Time; Time::make('Time')->withSteps(1);
The withSeconds
method sets a step of 1 which allows users to enter seconds.
<?php use Michielfb\Time\Time; Time::make('Time')->withSeconds();
The withMilliseconds
method sets a step of 0.001 which allows users to enter milliseconds.
<?php use Michielfb\Time\Time; Time::make('Time')->withMilliseconds();