Skip to content

Commit

Permalink
Prevent updating position column when is not dirty
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubdibala authored and pionl committed Apr 13, 2021
1 parent 995d31f commit 1633ae5
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/PositionObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public function saving($model)
if ($model->isPositionUpdateDisabled() === false) {
// Get the position for current and old value
$position = $model->getPosition();

// Prevent modifying position column when updating and position columns has not changed
if ($model->exists === true && $model->isDirty($model->getPositionColumn()) === false) {
return;
}

// Get the old position
$oldPosition = $model->getOriginal($model->getPositionColumn());
Expand Down

0 comments on commit 1633ae5

Please sign in to comment.