Coder Social home page Coder Social logo

nova-time-field's Introduction

A time field for Laravel Nova applications

Latest Version on Packagist StyleCI Total Downloads

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.

screenshot of the nova time field

Installation

You can install this package in your Laravel Nova app via composer:

composer require laraning/nova-time-field

Usage

You can use the Laraning\NovaTimeField\TimeField namespace in your Nova resource:

namespace App\Nova;

use Laraning\NovaTimeField\TimeField;

class BlogPost extends Resource
{
    // ...

    public function fields(Request $request)
    {
        return [
            // ...

            TimeField::make('Post start 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),

Current development status

  • Make release 0.1.0.
  • Add minimal test scenarios.
  • Add timezone support.

Changelog

Please see CHANGELOG for more information on what has changed recently.

License

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

nova-time-field's People

Contributors

alexanderbich avatar brandonferens avatar brunocfalcao avatar chrispelzer avatar darylldoyle avatar digitalunityca avatar ghulamappelit avatar joonas1234 avatar laraning avatar simonfunk avatar tiagosilvapereira avatar tylernathanreed avatar zareismail avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

nova-time-field's Issues

Validation message showing twice

Validation message is showing twice when using required rule.

Using only one field:

TimeField::make(__('Working Hours From'))->withTwelveHourTime()->sortable()->rules('required')

Screenshot_2020-05-09 admin-single time field

Using two fields:

TimeField::make(__('Working Hours From'))->withTwelveHourTime()->sortable()->rules('required'),
TimeField::make(__('Working Hours To'))->withTwelveHourTime()->sortable()->rules('required')

Screenshot_2020-05-09 admin

Version: 0.2.5

Field does not react to changes unless date picker is open

  • laraning/nova-time-field v1.2
  • laravel/nova v3.27.0
  • laravel/framework v8.52.0
  • Browser: Google Chrome on MacOS

Steps to reproduce

  1. Start by pressing down the mouse button with the cursor inside of the input field.
    a. Notice that the date picker opens.
  2. Move the cursor outside of the input field before releasing the mouse button.
    a. Notice that the date picker closes.
  3. The field is now selected. Enter a time.
  4. At this point, if you save, the value you entered will not be sent to the backend, but rather the value that was in the field before step 1.

This happened to me a several times because of my tendency to drag my mouse across the input field in order to select all the text, and in most cases I would apparently release the mouse button outside of the input field.

I suspect that the reason this happens is because TimePicker.vue listens for flatpickr's onClose event, which is only triggered when the date picker closes. Perhaps the solution is to hook into the onChange event instead/as well?

Thanks for creating this package! Let me know if you need more info ๐Ÿ™‚

Using ->rules makes the Field disappear

Hello,

i'm using Laravel Nova 2.0.5 and i just started using TimeField.
I wanted to add
"->rules('required')" to my TimeField but if i do the Field just disappears in the Nova Backend.

Action with TimeField not working

  • Laravel Version: 8.60.0
  • Nova Version: 3.30.0
  • Browsers: Firefox 93.0, Chrome 94.0, Safari 15.0

Description:

When you open a time picker and start changing the time, the action modal closes.

Action with TimeField works fine on Nova 3.29.0.

Screenshot 2021-10-27 at 15 15 31

The field must contain a valid time

  • Laravel Version: 7.29.3
  • Nova Version: 3.15.9
  • PHP Version: 7.4.3
  • Database Driver & Version: Mysql 8.0.22
  • Operating System and Version:Ubuntu 20.04.1 LTS

Description:

I moved my project from dev (MacOS 11.0.1) to prod (Ubuntu 20.04.1) and now my DateTime field doesn't work. Here is the log:

[2020-11-19 11:40:30] production.ERROR: The field must contain a valid time. {"userId":1,"exception":"[object] (Exception(code: 0): The field must contain a valid time. at /var/www/skyride/vendor/laraning/nova-time-field/src/TimeField.php:89)
[stacktrace]
#0 /var/www/skyride/vendor/laravel/nova/src/Fields/Field.php(362): Laraning\\NovaTimeField\\TimeField->fillAttributeFromRequest()
#1 /var/www/skyride/vendor/laravel/nova/src/Fields/Field.php(341): Laravel\\Nova\\Fields\\Field->fillAttribute()
#2 /var/www/skyride/vendor/laravel/nova/src/Fields/Field.php(315): Laravel\\Nova\\Fields\\Field->fillInto()
#3 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Support/HigherOrderCollectionProxy.php(60): Laravel\\Nova\\Fields\\Field->fill()
#4 [internal function]: Illuminate\\Support\\HigherOrderCollectionProxy->Illuminate\\Support\\{closure}()
#5 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Support/Collection.php(638): array_map()
#6 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Support/HigherOrderCollectionProxy.php(61): Illuminate\\Support\\Collection->map()
#7 /var/www/skyride/vendor/laravel/nova/src/FillsFields.php(85): Illuminate\\Support\\HigherOrderCollectionProxy->__call()
#8 /var/www/skyride/app/Nova/Resource.php(82): Laravel\\Nova\\Resource::fillFields()
#9 /var/www/skyride/vendor/laravel/nova/src/Http/Controllers/ResourceStoreController.php(28): App\\Nova\\Resource::fill()
#10 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Database/Concerns/ManagesTransactions.php(28): Laravel\\Nova\\Http\\Controllers\\ResourceStoreController->Laravel\\Nova\\Http\\Controllers\\{closure}()
#11 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(367): Illuminate\\Database\\Connection->transaction()
#12 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(261): Illuminate\\Database\\DatabaseManager->__call()
#13 /var/www/skyride/vendor/laravel/nova/src/Http/Controllers/ResourceStoreController.php(44): Illuminate\\Support\\Facades\\Facade::__callStatic()
#14 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): Laravel\\Nova\\Http\\Controllers\\ResourceStoreController->handle()
#15 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(45): Illuminate\\Routing\\Controller->callAction()
#16 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Route.php(239): Illuminate\\Routing\\ControllerDispatcher->dispatch()
#17 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Route.php(196): Illuminate\\Routing\\Route->runController()
#18 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Router.php(685): Illuminate\\Routing\\Route->run()
#19 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Routing\\Router->Illuminate\\Routing\\{closure}()
#20 /var/www/skyride/vendor/vyuldashev/nova-permission/src/ForgetCachedPermissions.php(22): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#21 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Vyuldashev\\NovaPermission\\ForgetCachedPermissions->handle()
#22 /var/www/skyride/vendor/laravel/nova/src/Http/Middleware/Authorize.php(18): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#23 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Laravel\\Nova\\Http\\Middleware\\Authorize->handle()
#24 /var/www/skyride/vendor/laravel/nova/src/Http/Middleware/BootTools.php(20): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#25 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Laravel\\Nova\\Http\\Middleware\\BootTools->handle()
#26 /var/www/skyride/vendor/laravel/nova/src/Http/Middleware/DispatchServingNovaEvent.php(20): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#27 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Laravel\\Nova\\Http\\Middleware\\DispatchServingNovaEvent->handle()
#28 /var/www/skyride/app/Http/Middleware/CheckNovaAdmin.php(23): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#29 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): App\\Http\\Middleware\\CheckNovaAdmin->handle()
#30 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#31 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Routing\\Middleware\\SubstituteBindings->handle()
#32 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(44): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#33 /var/www/skyride/vendor/laravel/nova/src/Http/Middleware/Authenticate.php(31): Illuminate\\Auth\\Middleware\\Authenticate->handle()
#34 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Laravel\\Nova\\Http\\Middleware\\Authenticate->handle()
#35 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(77): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#36 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken->handle()
#37 /var/www/skyride/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#38 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\View\\Middleware\\ShareErrorsFromSession->handle()
#39 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(116): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#40 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(62): Illuminate\\Session\\Middleware\\StartSession->handleStatefulRequest()
#41 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Session\\Middleware\\StartSession->handle()
#42 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#43 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse->handle()
#44 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(67): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#45 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Cookie\\Middleware\\EncryptCookies->handle()
#46 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#47 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Router.php(687): Illuminate\\Pipeline\\Pipeline->then()
#48 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Router.php(662): Illuminate\\Routing\\Router->runRouteWithinStack()
#49 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Router.php(628): Illuminate\\Routing\\Router->runRoute()
#50 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Routing/Router.php(617): Illuminate\\Routing\\Router->dispatchToRoute()
#51 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(165): Illuminate\\Routing\\Router->dispatch()
#52 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Illuminate\\Foundation\\Http\\Kernel->Illuminate\\Foundation\\Http\\{closure}()
#53 /var/www/skyride/vendor/laravel/nova/src/Http/Middleware/ServeNova.php(26): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#54 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Laravel\\Nova\\Http\\Middleware\\ServeNova->handle()
#55 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#56 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#57 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#58 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle()
#59 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#60 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle()
#61 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(63): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#62 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle()
#63 /var/www/skyride/vendor/fruitcake/laravel-cors/src/HandleCors.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#64 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle()
#65 /var/www/skyride/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#66 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fideloper\\Proxy\\TrustProxies->handle()
#67 /var/www/skyride/vendor/fruitcake/laravel-cors/src/HandleCors.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#68 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(167): Fruitcake\\Cors\\HandleCors->handle()
#69 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(103): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}()
#70 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(140): Illuminate\\Pipeline\\Pipeline->then()
#71 /var/www/skyride/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(109): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter()
#72 /var/www/skyride/public/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle()
#73 {main}
"} 

Detailed steps to reproduce the issue on a fresh Nova installation:

Nullable does not work.

Hi! There is no option to provide empty value. Every time I make field valueless, it is saved with value: 12:00:00

I run last version. Any help?

Placeholder wrong time

The placeholder is displaying seconds instead of minutes.
As opposed to moment(new Date()).format('HH:ss') it should probably be moment().format('HH:mm') (new Date() isn't necessary).

It would also be nice to be able to set the placeholder.

Unable to type a time into the field

When using this field, it seems that although the field is editable, it has no effect and is basically a readonly field from manual entry. Even if you type in the field, it is overwritten once the time picker closes with the default 12:00AM.

Exception Not Found

Most recent update broke my nova forms. See error message below posted to my slack:

Message
Class 'Laraning\NovaTimeField\Exception' not found
Level
ERROR
UserId
1
Exception

   "class": "Symfony\\Component\\Debug\\Exception\\FatalThrowableError",
   "message": "Class 'Laraning\\NovaTimeField\\Exception' not found",
   "code": 0,
   "file": "\/var\/app\/current\/vendor\/laraning\/nova-time-field\/src\/TimeField.php:67",
   "trace": [
       "\/var\/app\/current\/nova\/src\/Fields\/Field.php:317",
       "\/var\/app\/current\/nova\/src\/Fields\/Field.php:296",
       "\/var\/app\/current\/nova\/src\/Fields\/Field.php:270",
       "\/var\/app\/current\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/HigherOrderCollectionProxy.php:60",
       "{\"function\":\"Illuminate\\\\Support\\\\{closure}\",\"class\":\"Illuminate\\\\Support\\\\HigherOrderCollectionProxy\",\"type\":\"->\",\"args\":[\"[object] (Laraning\\\\NovaTimeField\\\\TimeField)\",12]}",
       "\/var\/app\/current\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Collection.php:1120",
       "\/var\/app\/current\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/HigherOrderCollectionProxy.php:61",
       "\/var\/app\/current\/nova\/src\/FillsFields.php:67",
       "\/var\/app\/current\/nova\/src\/FillsFields.php:20",
       "\/var\/app\/current\/nova\/src\/Http\/Controllers\/ResourceStoreController.php:28",
       "\/var\/app\/current\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/Concerns\/ManagesTransactions.php:29",
       "\/var\/app\/current\/vendor\/laravel\/framework\/src\/Illuminate\/Database\/DatabaseManager.php:349",
       "\/var\/app\/current\/vendor\/laravel\/framework\/src\/Illuminate\/Support\/Facades\/Facade.php:237",
       "\/var\/app\/current\/nova\/src\/Http\/Controllers\/ResourceStoreController.php:44",
       "{\"function\":\"handle\",\"class\":\"Laravel\\\\Nova\\\\Http\\\\Controllers\\\\ResourceStoreController\",\"type\":\"->\",\"args\":[\"[object] (Laravel\\\\Nova\\\\Http\\\\Requests\\\\CreateResourceRequest)\",\"days\"]}",
       "\/var\/app\/current\/vendor\/laravel\/framework\/src\/Illuminate\/Routinโ€ฆ
Today at 5:16 PM

Data Missing error

After upgrading to Laravel Nova 2.9.2 and Laravel 6.x I am not getting a Data Missing error when using this plugin. I was only storing the database with time as HH:mm:ss and now I can't convert back to DateTime.

Is there some modification I need to make to this package?

Message Data missing Level ERROR UserId 1 Exception { "class": "InvalidArgumentException", "message": "Data missing", "code": 0, "file": "/home/vagrant/code/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php:581", "trace": [ "/home/vagrant/code/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php:603", "/home/vagrant/code/vendor/laraning/nova-time-field/src/TimeField.php:32", "/home/vagrant/code/nova/src/Fields/Field.php:242",

Cant make it nullable.

Actually its working fine on required rules, but not working properly on nullable or sometimes rules.

TimeField::make(__('Start Time'), 'start_time')->rules('sometimes', 'nullable'),

Gives below error.

message: "The field must contain a valid time."
exception: "Exception"
file: "/vendor/laraning/nova-time-field/src/TimeField.php

Nova 2.0 support

I just installed the package in a fresh Nova 2.0 installation and the styling is off. The error messages do not look the same anymore.

There are also some functional problems. But someone already made a pr for that: #3

Time Range

Can you add time range on this package? so user can select time such as from 08.00 to 12.00
Thanks

Help text not shown

It would be really awesome to have the help text show up for this component. Currently it does not show.

Javascript error in v1.1

I'm consistently getting the following javascript error with v1.1:

image

The error prevents the field from saving its value. Reverting to v1.0 fixes the problem.

My fields are defined very simply:

TimeField::make(__('Start Time'), 'start_time')
                ->rules(['required', 'before:end_time']),

TimeField::make(__('End Time'), 'end_time')
                ->rules(['required', 'after:start_time']),

Let me know if I can provide any additional info

Problem when retrieve data from MsSQL when field TIME(7)

When I edit on Nova the record with field TIME(7) from a Microsoft SQL Server, the value returns in following format:

H:i:s.Z

Example: 09:00:00.0000000

So, a error happens:

{
    "message": "Trailing data",
    "exception": "Carbon\\Exceptions\\InvalidFormatException",
    "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\nesbot\\carbon\\src\\Carbon\\Traits\\Creator.php",
    "line": 675,
    "trace": [
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\nesbot\\carbon\\src\\Carbon\\Traits\\Creator.php",
            "line": 698,
            "function": "rawCreateFromFormat",
            "class": "Carbon\\Carbon",
            "type": "::"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laraning\\nova-time-field\\src\\TimeField.php",
            "line": 39,
            "function": "createFromFormat",
            "class": "Carbon\\Carbon",
            "type": "::"
        },
        {
            "function": "Laraning\\NovaTimeField\\{closure}",
            "class": "Laraning\\NovaTimeField\\TimeField",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Fields\\Field.php",
            "line": 252,
            "function": "call_user_func"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\helpers.php",
            "line": 263,
            "function": "Laravel\\Nova\\Fields\\{closure}",
            "class": "Laravel\\Nova\\Fields\\Field",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Fields\\Field.php",
            "line": 253,
            "function": "tap"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Fields\\Field.php",
            "line": 221,
            "function": "resolve",
            "class": "Laravel\\Nova\\Fields\\Field",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\ResolvesFields.php",
            "line": 95,
            "function": "resolveForDisplay",
            "class": "Laravel\\Nova\\Fields\\Field",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Collections\\Traits\\EnumeratesValues.php",
            "line": 234,
            "function": "Laravel\\Nova\\{closure}",
            "class": "Laravel\\Nova\\Resource",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\ResolvesFields.php",
            "line": 97,
            "function": "each",
            "class": "Illuminate\\Support\\Collection",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\ResolvesFields.php",
            "line": 179,
            "function": "detailFields",
            "class": "Laravel\\Nova\\Resource",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Resource.php",
            "line": 458,
            "function": "detailFieldsWithinPanels",
            "class": "Laravel\\Nova\\Resource",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Http\\Controllers\\ResourceShowController.php",
            "line": 27,
            "function": "serializeForDetail",
            "class": "Laravel\\Nova\\Resource",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Controller.php",
            "line": 54,
            "function": "handle",
            "class": "Laravel\\Nova\\Http\\Controllers\\ResourceShowController",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\ControllerDispatcher.php",
            "line": 45,
            "function": "callAction",
            "class": "Illuminate\\Routing\\Controller",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
            "line": 254,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\ControllerDispatcher",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Route.php",
            "line": 197,
            "function": "runController",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 695,
            "function": "run",
            "class": "Illuminate\\Routing\\Route",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 128,
            "function": "Illuminate\\Routing\\{closure}",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Http\\Middleware\\Authorize.php",
            "line": 18,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Laravel\\Nova\\Http\\Middleware\\Authorize",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Http\\Middleware\\BootTools.php",
            "line": 20,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Laravel\\Nova\\Http\\Middleware\\BootTools",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Http\\Middleware\\DispatchServingNovaEvent.php",
            "line": 20,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Laravel\\Nova\\Http\\Middleware\\DispatchServingNovaEvent",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Middleware\\SubstituteBindings.php",
            "line": 50,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Routing\\Middleware\\SubstituteBindings",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Auth\\Middleware\\Authenticate.php",
            "line": 44,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Http\\Middleware\\Authenticate.php",
            "line": 31,
            "function": "handle",
            "class": "Illuminate\\Auth\\Middleware\\Authenticate",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Laravel\\Nova\\Http\\Middleware\\Authenticate",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken.php",
            "line": 78,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\VerifyCsrfToken",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\View\\Middleware\\ShareErrorsFromSession.php",
            "line": 49,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\View\\Middleware\\ShareErrorsFromSession",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php",
            "line": 121,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Session\\Middleware\\StartSession.php",
            "line": 64,
            "function": "handleStatefulRequest",
            "class": "Illuminate\\Session\\Middleware\\StartSession",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Session\\Middleware\\StartSession",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse.php",
            "line": 37,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Cookie\\Middleware\\AddQueuedCookiesToResponse",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Cookie\\Middleware\\EncryptCookies.php",
            "line": 67,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Cookie\\Middleware\\EncryptCookies",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 103,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 697,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 672,
            "function": "runRouteWithinStack",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 636,
            "function": "runRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Routing\\Router.php",
            "line": 625,
            "function": "dispatchToRoute",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
            "line": 166,
            "function": "dispatch",
            "class": "Illuminate\\Routing\\Router",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 128,
            "function": "Illuminate\\Foundation\\Http\\{closure}",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\nova\\src\\Http\\Middleware\\ServeNova.php",
            "line": 26,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Laravel\\Nova\\Http\\Middleware\\ServeNova",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull.php",
            "line": 31,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest.php",
            "line": 21,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\TrimStrings.php",
            "line": 40,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\TrimStrings",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize.php",
            "line": 27,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance.php",
            "line": 86,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\fruitcake\\laravel-cors\\src\\HandleCors.php",
            "line": 38,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Fruitcake\\Cors\\HandleCors",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\fideloper\\proxy\\src\\TrustProxies.php",
            "line": 57,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 167,
            "function": "handle",
            "class": "Fideloper\\Proxy\\TrustProxies",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Pipeline\\Pipeline.php",
            "line": 103,
            "function": "Illuminate\\Pipeline\\{closure}",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
            "line": 141,
            "function": "then",
            "class": "Illuminate\\Pipeline\\Pipeline",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Http\\Kernel.php",
            "line": 110,
            "function": "sendRequestThroughRouter",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        },
        {
            "file": "D:\\Customers\\monumenta\\bb\\tmj\\E_Sports_Api\\public\\index.php",
            "line": 52,
            "function": "handle",
            "class": "Illuminate\\Foundation\\Http\\Kernel",
            "type": "->"
        }
    ]
}

Then I solved editing the file vendor/laraning/nova-time-field/src/TimeField.php and changed the code at Line 29:

    /**
     * Create a new field.
     *
     * @param string      $name
     * @param string|null $attribute
     * @param mixed|null  $resolveCallback
     *
     * @return void
     */
    public function __construct($name, $attribute = null, $resolveCallback = null)
    {
        parent::__construct($name, $attribute, $resolveCallback ?? function ($value) {
            if (is_null($value)) {
                return '';
            } else if (strpos($value, '.') > 0) {
                $pieces = explode('.', $value);
                $value = $pieces[0];
            }

            return Carbon::createFromFormat('H:i:s', $value)->format($this->format());
        });
    }

12 Hour Format in Update Form

I'm trying to make the 12 hour format appear consistent across the UI.

I've created a datetime column on a table that I'm managing the time portion of that field using this package.

Here's the magic accessor on the model that I created to yield just the time portion:

/**
 * Creates the $this->start_time attribute for the Nova framework.
 *
 * @return \Carbon\Carbon|null
 */
public function getStartTimeAttribute()
{
    return !is_null($this->starts_at) ? carbon($this->starts_at)->format('H:i:s') : null;
}

And here's the field declaration in my resource:

TimeField::make('Start Time', 'start_time', function($value, $resource) {
    return Carbon::createFromFormat('H:i:s', $value)->format('g:i A');
})->withTwelveHourTime(),

On the Index, Detail, and Create pages, this value appears correctly (in the HH:MM AM/PM) format. However, on the Update page, the AM/PM information gets lost (i.e. 1:30 PM becomes 1:30 AM).

I would like the 12 hour format to show as 12 hours on the Update form as well (and not 13:30 instead of 1:30 PM).

Is there a feature that I'm missing, or this a bug with the package?

Based on some initial research, it looks like this package is assuming a 24 hour date format regardless of the 12 hour time preference. I believe all that needs to be done here is to conditionally change the dateFormat option into flatpickr.

Wrong format in constructor

Time data in my (MySQL) database is saved in H:i:s format. The time field tries to reconstitute the value by using H:i. This throws an InvalidArgumentException:

/vendor/laraning/nova-time-field/src/TimeField.php(31): Carbon\\Carbon::createFromFormat('H:i', 'xx:xx:xx')

So as far as I can tell, the following line...

return Carbon::createFromFormat('H:i', $value)->format('H:i');

...sould be:

return Carbon::createFromFormat('H:i:s', $value)->format('H:i'); 

Another option would be to make both in the input and output formats configurable.

Error when field is casted as datetime

Hello,

Laravel only allows to cast time as datetime, which means that when a set my column name in the casted array, nova-time-field throws an error as it expects a certain format. Is it possible to change

Carbon::createFromFormat('H:i:s', $value)

to

Carbon::parse($value)

in TimeField.php?

Cheers

It Doesn't Work With Date Mutators

This field works perfectly fine on nova and the front end, but I added a date mutator to the model so that I could format the date:

public function getStartTimeAttribute($value) { return \Carbon\Carbon::parse($value)->format('g:ia'); }

This works flawlessly on the front end but when trying to go back into Nova it gives an error:

A two digit second could not be found

So I tried:

TimeField::make('Start Time', function(){ return Carbon::parse($this->start_time)->format('g:i'); }),

And it sows on the detail and list views but the fields are not shown on the edit page.

Any ideas?

Maybe adding ->format() as a method to the field would resolve this issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.