From 28f847f0033d0b7150593d7b0a9f2740c30d3cde Mon Sep 17 00:00:00 2001 From: Markus Podar Date: Thu, 20 Aug 2020 15:34:34 +0200 Subject: [PATCH] Make HasTimestamps::updateTimestamps public (#33953) 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. --- src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php b/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php index 8de099c998cd..f820bf7aa9eb 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php @@ -34,7 +34,7 @@ public function touch() * * @return void */ - protected function updateTimestamps() + public function updateTimestamps() { $time = $this->freshTimestamp();