How to use Laravel Nova Time field

laravel nova time field

How to use Laravel Nova Time field. This package contains a Nova field to allow you to store time values. Under the hood it uses the flatpickr default Laravel Nova Calendar library.

laravel nova time field

How to use Laravel Nova Time field

Getting Started

Prerequisites

This package requires the following :

  • PHP 8.0 or higher
  • Laravel Nova 4.0 or higher

Installing

To get started, you will need to install the following dependencies :

composer require oneduo/nova-time-field

That’s it, you’re ready to go!

Usage

How to use Laravel Nova Time field. You may use the Time in your Nova resource :

// app/Nova/User.php

use Oneduo\NovaTimeField\Time;

class User extends Resource
{
    // ...

    public function fields(NovaRequest $request): array
    {
        return [
            // ... any other fields
            Time::make(__('time'), 'time'),
        ];
    }
}

By default the time component uses a 24 hour format. Still you can make it in 12h format like:

TimeField::make('Post start Time')->withTwelveHourTime(),

You can also change the default 5 minute increments to another number:

TimeField::make('Post start Time')->minuteIncrement(1),

You can make sure that all times entered are converted back to your base app timezone (set in config/app.php) by calling the withTimezoneAdjustments() method on your field.

TimeField::make('Post start Time')->withTimezoneAdjustments(),

An example of this would be when your app is set to GMT but your user is in BST (GMT+1). The user would still be able to interact with the timefield in their local time, but the time would be saved into the database in GMT.

E.G. The user may select 14:00. They will always see the time as 14:00, but the database will save it as 13:00 as it makes the BST -> GMT adjustments behind the scenes.

As well as handling switching the time to and from your base app timezone, you may also pass in a timezone offset (in minutes), such as the one returned by moment().utcOffset(). This will then adjust the time to display with the adjusted timezone rather than the users timezone. This is useful if you’re saving the time in UTC along with the offset of the browser that was used to submit it.

Here you can see how we’d move UTC to BST by passing an offset of 60

TimeField::make('Post start Time')->withTimezoneAdjustments(60),

Authors

See also the list of contributors who participated in this project.

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

Please review our security policy on how to report security vulnerabilities.

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

Source : https://github.com/laraning/nova-time-field

Keywords:

  • novapackages
  • How to use Laravel Nova Time field
  • laravel nova
  • laravel time field

brillian

Leave a Reply

%d bloggers like this:
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Adblockers perform their job via blocking communication with ad-forcing servers, and by hiding the webpage elements containing commercial content. By referring to filter lists containing the addresses of ad servers, ad blockers seek matches in website elements and define what should be blocked.

Adblocking detection in its turn is performed through “bait content”. Invisible to the user, such bait is implemented the way adblockers recognize it as commercial content. As soon as the webpage finishes loading, the detection algorithm calls to the properties of the bait. If the bait is hidden, the algorithm recognizes that there’s an active adblocker. Although baits are different and have different levels of complexity, it’s not that hard to disable adblock detection.

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock