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