Skip to content

Commit

Permalink
1.) added: amend to properly re-order when deleting
Browse files Browse the repository at this point in the history
Signed-off-by: Oskars Germovs <[email protected]>
  • Loading branch information
Faks committed Nov 24, 2024
1 parent 8a3bd63 commit f53e5a6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/SortableTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ public static function bootSortableTrait(): void

static::deleting(function (Model $model): void {
if (($model instanceof Sortable || $model instanceof Model) && $model->shouldSortWhenDeleting()) {
self::setMassNewOrder($model->sortables);
self::setMassNewOrder(
$model::query()->ordered()->where('id', '!=', $model->id)->pluck('id')->toArray()
);
}
});
}
Expand Down

0 comments on commit f53e5a6

Please sign in to comment.