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