Skip to content

Commit

Permalink
[10.x] Extract dirty getter for performUpdate (#49141)
Browse files Browse the repository at this point in the history
  • Loading branch information
taka-oyama authored Nov 27, 2023
1 parent d8a0931 commit 9337c0e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Database/Eloquent/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 9337c0e

Please sign in to comment.