Skip to content

Conversation

antonkomarev
Copy link
Contributor

This PR replaces #34785 targeted to 8.x because @GrahamCampbell said to target this changes to 6.x

Eloquent Model constants CREATED_AT & UPDATED_AT are nullable. There are checks for null values, but null is not documented in PHPDoc.

public function updateTimestamps()
{
    $time = $this->freshTimestamp();

    $updatedAtColumn = $this->getUpdatedAtColumn();

    if (! is_null($updatedAtColumn) && ! $this->isDirty($updatedAtColumn)) {
        $this->setUpdatedAt($time);
    }

    $createdAtColumn = $this->getCreatedAtColumn();

    if (! $this->exists && ! is_null($createdAtColumn) && ! $this->isDirty($createdAtColumn)) {
        $this->setCreatedAt($time);
    }
}

@antonkomarev antonkomarev changed the base branch from 8.x to 6.x October 10, 2020 23:49
@taylorotwell taylorotwell merged commit 2bf90d2 into laravel:6.x Oct 11, 2020
@antonkomarev antonkomarev deleted the fix-eloquent-model-timestamp-types branch October 11, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants