I have just upgraded from Laravel 6 (PHP 7.4) to Laravel 7 (PHP 7.4) and casting dates in a model has completely stopped working.
For example, in my User model, I have the following $dates
array:
protected $dates = [
'online_at'
];
The following is returned: 2020-08-17T00:00:00.000000Z
yet I am expecting a Carbon object to be returned.
The field in the MySQL database is DATETIME.
The same is happening with the created_at
, updated_at
, and deleted_at
fields. It's also the same across all models.
I have tried moving the field into the $casts
array but I get the same result.
Any help would be much appreciated.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…