@@ 139-153 (lines=15) @@ | ||
136 | * |
|
137 | * @return $this |
|
138 | */ |
|
139 | public function moveOrderDown() |
|
140 | { |
|
141 | $orderColumnName = $this->determineOrderColumnName(); |
|
142 | ||
143 | $swapWithModel = $this->buildSortQuery()->limit(1) |
|
144 | ->ordered() |
|
145 | ->where($orderColumnName, '>', $this->$orderColumnName) |
|
146 | ->first(); |
|
147 | ||
148 | if (! $swapWithModel) { |
|
149 | return $this; |
|
150 | } |
|
151 | ||
152 | return $this->swapOrderWithModel($swapWithModel); |
|
153 | } |
|
154 | ||
155 | /** |
|
156 | * Swaps the order of this model with the model 'above' this model. |
|
@@ 160-174 (lines=15) @@ | ||
157 | * |
|
158 | * @return $this |
|
159 | */ |
|
160 | public function moveOrderUp() |
|
161 | { |
|
162 | $orderColumnName = $this->determineOrderColumnName(); |
|
163 | ||
164 | $swapWithModel = $this->buildSortQuery()->limit(1) |
|
165 | ->ordered('desc') |
|
166 | ->where($orderColumnName, '<', $this->$orderColumnName) |
|
167 | ->first(); |
|
168 | ||
169 | if (! $swapWithModel) { |
|
170 | return $this; |
|
171 | } |
|
172 | ||
173 | return $this->swapOrderWithModel($swapWithModel); |
|
174 | } |
|
175 | ||
176 | /** |
|
177 | * Swap the order of this model with the order of another model. |