问题
I have field last_active on users, I want display time with diffForHumans or time_from_now
from Moment.js. How I can do it? Now I just use:
DateTime::make('Activiy', 'last_active')
->exceptOnForms(),
When I use:
DateTime::make('Activiy', 'last_active')->diffForHumans()
->exceptOnForms(),
I get undifined method diffForHumans
.
回答1:
To my knowledge at the moment DateTime
only supports format
.
Since you want only to display, you can try Text
field & display the humanise value.
Text::make('Activiy', 'last_active')
->displayUsing(function($lastActive) {
return $lastActive->diffForHumans();
})
->exceptOnForms(),
来源:https://stackoverflow.com/questions/54265324/laravel-nova-diffforhumans-datetime