-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
- Laravel Version: 5.7.15
- Nova Version: 1.2.0
- PHP Version: 7.2.12
Description:
When wanting to display a date (not a datetime) field I have the following error
date field must cast to 'date' in eloquent model
I already posted in laracasts nova's channel but there is no solution right now
https://laracasts.com/discuss/channels/nova/date-field-must-cast-to-date-in-eloquent-model-and-it-is
Steps To Reproduce:
I cast the date fields as this in the eloquent model :
protected $dates = [
'created_at' => 'datetime:Y-m-d H:i:s',
'updated_at' => 'datetime:Y-m-d H:i:s',
'deleted_at' => 'datetime:Y-m-d H:i:s',
'billed_at' => 'date:Y-m-d',
'payed_at' => 'date:Y-m-d',
'due_date' => 'date:Y-m-d',
];
I also tested
protected $casts = [,
'billed_at' => 'date',
'payed_at' => 'date',
'due_date' => 'date',
];
created_at
,updated_at
anddeleted_at
are stored as TIMESTAMP (no issue)billed_at
,payed_at
anddue_date
are stored as DATE in Mysql
In my Nova Resource, if I use the Date field I have the error
date field must cast to 'date' in eloquent model
And this is how the fields are set
Date::make('Billed At', 'billed_at'),
Date::make('Payed At', 'payed_at'),
Date::make('Due Date', 'due_date'),
Metadata
Metadata
Assignees
Labels
No labels