Skip to content
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

[5.7] Allow to disable CREATED_AT in Models #23648

Merged
merged 2 commits into from
Mar 21, 2018

Conversation

TBlindaruk
Copy link
Contributor

@TBlindaruk TBlindaruk commented Mar 21, 2018

Problem

We can disable the UPDATED_AT timestamp in Eloquent (just set the const CREATET_AT to null).

class UserWithCreated extends Eloquent
{
    public const UPDATED_AT = null;

    protected $table = 'users_created_at';
}

After this disabling CREATED_AT will work as expected.

But we cannot disable just CREATED_AT constant.
We got the error

Illuminate\Tests\Database\DatabaseEloquentTimestamps::testUserWithUpdatedAt
ArgumentCountError: Too few arguments to function Illuminate\Database\Eloquent\Model::setAttribute(), 1 passed in
/framework/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php on line 548 and exactly 2 expected


This PR is allowed to set CREATED_AT to null;

It was already proposed and rejected in
#22990
and
#23638

I have created a Unit test as @tillkruss asked.


(cherry picked from commit 273b7fc)
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.

None yet

2 participants