Skip to content

[5.5] Model can work without updated_at column #20930

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

Closed
wants to merge 2 commits into from
Closed

[5.5] Model can work without updated_at column #20930

wants to merge 2 commits into from

Conversation

antonkomarev
Copy link
Contributor

Related to: #20901 and #19627 (comment)

Adds ability to define if model has no updated_at column.

If $withoutUpdatedAt property exists and true - skip handling of updated_at column updates.

ModelWithoutUpdatedAt extends Model
{
    public $withoutUpdatedAt = true;
}

@taylorotwell
Copy link
Member

No plans to allow only 1 timestamp.

@antonkomarev antonkomarev deleted the feature/without-updated-at branch September 2, 2017 11:35
@antonkomarev
Copy link
Contributor Author

Is there any reason of it? Could this question be a bit more illuminated to let people know why they'd better prefer to have updated_at columns in all their models? Thanks.

@BrandonSurowiec
Copy link
Contributor

BrandonSurowiec commented Sep 3, 2017

@a-komarev In one of my legacy projects that I was converting to Laravel I made the model only use the created at timestamp by adding:

    /**
     * The name of the "updated at" column.
     *
     * @var string
     */
    const UPDATED_AT = null;

Into my model. I'm sure if you switch that to const CREATED_AT = null; you can get the behavior you desire.

(Edit: I just noticed the PR you mentioned that broke it. ) Looks like you figured out a nice workaround by using a mutator to make setCreatedAtAttribute do nothing. #20901 (comment)

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.

3 participants