@@ 122-136 (lines=15) @@ | ||
119 | * |
|
120 | * @return $this |
|
121 | */ |
|
122 | public function moveOrderDown() |
|
123 | { |
|
124 | $orderColumnName = $this->determineOrderColumnName(); |
|
125 | ||
126 | $swapWithModel = $this->buildSortQuery()->limit(1) |
|
127 | ->ordered() |
|
128 | ->where($orderColumnName, '>', $this->$orderColumnName) |
|
129 | ->first(); |
|
130 | ||
131 | if (! $swapWithModel) { |
|
132 | return $this; |
|
133 | } |
|
134 | ||
135 | return $this->swapOrderWithModel($swapWithModel); |
|
136 | } |
|
137 | ||
138 | /** |
|
139 | * Swaps the order of this model with the model 'above' this model. |
|
@@ 143-157 (lines=15) @@ | ||
140 | * |
|
141 | * @return $this |
|
142 | */ |
|
143 | public function moveOrderUp() |
|
144 | { |
|
145 | $orderColumnName = $this->determineOrderColumnName(); |
|
146 | ||
147 | $swapWithModel = $this->buildSortQuery()->limit(1) |
|
148 | ->ordered('desc') |
|
149 | ->where($orderColumnName, '<', $this->$orderColumnName) |
|
150 | ->first(); |
|
151 | ||
152 | if (! $swapWithModel) { |
|
153 | return $this; |
|
154 | } |
|
155 | ||
156 | return $this->swapOrderWithModel($swapWithModel); |
|
157 | } |
|
158 | ||
159 | /** |
|
160 | * Swap the order of this model with the order of another model. |