From bdab2ba5bcf6dc41334b221a8bd33e70ce93cf3d Mon Sep 17 00:00:00 2001 From: freek Date: Fri, 5 Feb 2021 16:24:48 +0100 Subject: [PATCH 1/2] wip --- .../Database/Eloquent/Concerns/HasTimestamps.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php b/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php index 13ebd31744cd..dd00f5df8f31 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php @@ -16,10 +16,17 @@ trait HasTimestamps /** * Update the model's update timestamp. * + * @param string $attribute * @return bool */ - public function touch() + public function touch($attribute = null) { + if ($attribute) { + $this->$attribute = $this->freshTimestamp(); + + return $this->save(); + } + if (! $this->usesTimestamps()) { return false; } From 6e12690e389703bb2cef3f35926b991ded514347 Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Sun, 7 Feb 2021 13:45:44 +0100 Subject: [PATCH 2/2] Update HasTimestamps.php --- 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 dd00f5df8f31..add911ae8619 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php @@ -16,7 +16,7 @@ trait HasTimestamps /** * Update the model's update timestamp. * - * @param string $attribute + * @param string|null $attribute * @return bool */ public function touch($attribute = null)