In Laravel 8 the $dates cast was deprecated in favor of using the exitinsg $casts property - in Laravel 10 it is removed entirely. This PR removes the deprecated property and moves date casting to the existing $casts array.
Here is how the change looks:
class User extends Model
{
protected $casts = [
'isAdmin' => 'boolean',
+ 'lastLogin' => 'date'
];
- protected $dates = [
- 'lastLogin'
- ];
}
This approach of handling date casts is supported as far back as Laravel 5.1 so there should be no compatability issues with existing codebases. The only breaking change here is for people who directly accessed the $dates property for whatever reason. If you still need access to only date casts, then the following method can be added to return the same data that would have been held in the property.
public function dates()
{
return array_keys(array_filter($this->casts, function (string $cast) {
return $cast === 'date';
}));
}
In Laravel 8 the
$dates
cast was deprecated in favor of using the exitinsg $casts property - in Laravel 10 it is removed entirely. This PR removes the deprecated property and moves date casting to the existing$casts
array.Here is how the change looks:
This approach of handling date casts is supported as far back as Laravel 5.1 so there should be no compatability issues with existing codebases. The only breaking change here is for people who directly accessed the
$dates
property for whatever reason. If you still need access to only date casts, then the following method can be added to return the same data that would have been held in the property.Fixes #234