Open
Description
Hello -
I'm facing an issue when the value of a date is null
instead of being a date. I understand that value 'null' should not be stored as date in mongodb but it happens.
As a workaround I have implemented this small change in Eloquent/Model.php (l.98)
/**
* @inheritdoc
*/
protected function asDateTime($value)
{
// Convert UTCDateTime instances.
if ($value instanceof UTCDateTime) {
return Carbon::createFromTimestamp($value->toDateTime()->getTimestamp());
}
if (isset($value)){
return parent::asDateTime($value);
}
return '';
}
Is there a better way to address this issue?