You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The castAttribute method is overloaded in the base Model class. Unlike in the Core Laravel hasAttributes trait, it is missing handling for null values. See this code snippet from Laravel:
if (is_null($value) && in_array($castType, static::$primitiveCastTypes)) {
return$value;
}
Steps to reproduce
class MyModel extends \MongoDB\Laravel\Eloquent\Model {
protected$casts = [
'my_date' => 'immutable_datetime',
];
}
$model = newMyModel();
$model->my_date; // Should be null, instead is current time.