From 21db73f72db3acf58e46672b48b2bee7dbd1c99a Mon Sep 17 00:00:00 2001 From: Craig Anderson Date: Mon, 24 Oct 2022 22:51:35 -0400 Subject: [PATCH] Add touchQuietly convenience method --- .../Database/Eloquent/Concerns/HasTimestamps.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php b/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php index 9f798b0c1cd1..2b6dfab6548e 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php @@ -43,6 +43,17 @@ public function touch($attribute = null) return $this->save(); } + /** + * Update the model's update timestamp without raising any events. + * + * @param string|null $attribute + * @return bool + */ + public function touchQuietly($attribute = null) + { + return static::withoutEvents(fn () => $this->touch($attribute)); + } + /** * Update the creation and update timestamps. *