Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Extract dirty getter for performUpdate #49141

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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