| @@ 121-135 (lines=15) @@ | ||
| 118 | return $this->sortable['sort_when_creating'] ?? true; |
|
| 119 | } |
|
| 120 | ||
| 121 | public function moveOrderDown() |
|
| 122 | { |
|
| 123 | $orderColumnName = $this->determineOrderColumnName(); |
|
| 124 | ||
| 125 | $swapWithModel = $this->buildSortQuery()->limit(1) |
|
| 126 | ->ordered() |
|
| 127 | ->where($orderColumnName, '>', $this->$orderColumnName) |
|
| 128 | ->first(); |
|
| 129 | ||
| 130 | if (! $swapWithModel) { |
|
| 131 | return $this; |
|
| 132 | } |
|
| 133 | ||
| 134 | return $this->swapOrderWithModel($swapWithModel); |
|
| 135 | } |
|
| 136 | ||
| 137 | public function moveOrderUp() |
|
| 138 | { |
|
| @@ 137-151 (lines=15) @@ | ||
| 134 | return $this->swapOrderWithModel($swapWithModel); |
|
| 135 | } |
|
| 136 | ||
| 137 | public function moveOrderUp() |
|
| 138 | { |
|
| 139 | $orderColumnName = $this->determineOrderColumnName(); |
|
| 140 | ||
| 141 | $swapWithModel = $this->buildSortQuery()->limit(1) |
|
| 142 | ->ordered('desc') |
|
| 143 | ->where($orderColumnName, '<', $this->$orderColumnName) |
|
| 144 | ->first(); |
|
| 145 | ||
| 146 | if (! $swapWithModel) { |
|
| 147 | return $this; |
|
| 148 | } |
|
| 149 | ||
| 150 | return $this->swapOrderWithModel($swapWithModel); |
|
| 151 | } |
|
| 152 | ||
| 153 | public function swapOrderWithModel(Sortable $otherModel) |
|
| 154 | { |
|