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

[7.x] Make HasTimestamps::updateTimestamps public #33953

Merged
merged 1 commit into from
Aug 20, 2020

Conversation

mfn
Copy link
Contributor

@mfn mfn commented Aug 20, 2020

Summary

I've a use-case where I construct models but can't save them yet but
they should reflect the state of new models as good as it gets,
including the timestamps for created/updated, which I want to do from
outside the model

Similar to the touch() method:

    public function touch()
    {
        if (! $this->usesTimestamps()) {
            return false;
        }

        $this->updateTimestamps();

        return $this->save();
    }

But I don't want to save the model yet.

I can call usesTimestamps() from outside the model as its
already public but not yet updateTimestamps, thus the PR.

I've a use-case where I construct models but can't save them yet but
they should reflect the state of new models as good as it gets,
including the timestamps for created/updated, which I want to do from
outside the model

Similar to the `touch()` method:
```php
    public function touch()
    {
        if (! $this->usesTimestamps()) {
            return false;
        }

        $this->updateTimestamps();

        return $this->save();
    }
```
But I don't want to save the model _yet_.

I can call `usesTimestamps()` from outside the model as its
already public but not yet `updateTimestamps`, thus the PR.
@taylorotwell taylorotwell merged commit 28f847f into laravel:7.x Aug 20, 2020
@mfn mfn deleted the mfn-pub-ts branch August 20, 2020 13:48
@GrahamCampbell
Copy link
Member

This is a major breaking change, and will be reverted on 7.x, and moved to 8.x.

@mfn
Copy link
Contributor Author

mfn commented Aug 24, 2020

Uh, thanks for the update and sorry for the trouble.

I tried to think about this but it didn't occur to me that relaxing the visibility might be such a problem.

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

3 participants