From 9337c0ecdb0dbd000e5f53300a2566054469581a Mon Sep 17 00:00:00 2001 From: Takayasu Oyama Date: Mon, 27 Nov 2023 23:45:18 +0900 Subject: [PATCH] [10.x] Extract dirty getter for performUpdate (#49141) --- .../Database/Eloquent/Concerns/HasAttributes.php | 10 ++++++++++ src/Illuminate/Database/Eloquent/Model.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index d4f86c52c2be..8385eef4eea9 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -2038,6 +2038,16 @@ public function getDirty() return $dirty; } + /** + * Get the attributes that have been changed since the last sync for an update operation. + * + * @return array + */ + protected function getDirtyForUpdate() + { + return $this->getDirty(); + } + /** * Get the attributes that were changed when the model was last saved. * diff --git a/src/Illuminate/Database/Eloquent/Model.php b/src/Illuminate/Database/Eloquent/Model.php index c10fac5b9e8b..9648d6b99df4 100644 --- a/src/Illuminate/Database/Eloquent/Model.php +++ b/src/Illuminate/Database/Eloquent/Model.php @@ -1207,7 +1207,7 @@ protected function performUpdate(Builder $query) // Once we have run the update operation, we will fire the "updated" event for // this model instance. This will allow developers to hook into these after // models are updated, giving them a chance to do any special processing. - $dirty = $this->getDirty(); + $dirty = $this->getDirtyForUpdate(); if (count($dirty) > 0) { $this->setKeysForSaveQuery($query)->update($dirty);