-
-
Notifications
You must be signed in to change notification settings - Fork 142
Closed
Description
Hi,
the method "moveToStart" doesn't seem to work well. It increments all rows except the current model and this is not correct.
The current code is:
$this->$orderColumnName = $firstModel->$orderColumnName;
$this->save();
$this->buildSortQuery()->where($this->getKeyName(), '!=', $this->getKey())->increment($orderColumnName);
If I'm not wrong, the query should have another where clause to scope and increment only the previous rows, something like this:
$previousOrder = $this->$orderColumnName;
$this->$orderColumnName = $firstModel->$orderColumnName;
$this->save();
$this->buildSortQuery()
->where($this->getKeyName(), '!=', $this->getKey())
->where($this->getKeyName(), '<', $previousOrder)
->increment($orderColumnName);
Please, let me know if I'm missing something.
Thanks in advance!
Metadata
Metadata
Assignees
Labels
No labels