Skip to content

Question/Error when a date is null #1458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mattdalmau opened this issue Mar 8, 2018 · 0 comments
Open

Question/Error when a date is null #1458

mattdalmau opened this issue Mar 8, 2018 · 0 comments
Labels
Needs investigation Need investigation about bugs described in issue question

Comments

@mattdalmau
Copy link

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?

@divine divine added Needs investigation Need investigation about bugs described in issue question labels Feb 16, 2020
@divine divine mentioned this issue Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs investigation Need investigation about bugs described in issue question
Projects
None yet
Development

No branches or pull requests

2 participants