@@ 103-117 (lines=15) @@ | ||
100 | * |
|
101 | * @return bool|$this |
|
102 | */ |
|
103 | public function moveOrderDown() |
|
104 | { |
|
105 | $orderColumnName = $this->determineOrderColumnName(); |
|
106 | ||
107 | $swapWithModel = static::limit(1) |
|
108 | ->ordered() |
|
109 | ->where($orderColumnName, '>', $this->$orderColumnName) |
|
110 | ->first(); |
|
111 | ||
112 | if (!$swapWithModel) { |
|
113 | return false; |
|
114 | } |
|
115 | ||
116 | return $this->swapOrderWithModel($swapWithModel); |
|
117 | } |
|
118 | ||
119 | /** |
|
120 | * Swaps the order of this model with the model 'above' this model |
|
@@ 124-138 (lines=15) @@ | ||
121 | * |
|
122 | * @return bool|$this |
|
123 | */ |
|
124 | public function moveOrderUp() |
|
125 | { |
|
126 | $orderColumnName = $this->determineOrderColumnName(); |
|
127 | ||
128 | $swapWithModel = static::limit(1) |
|
129 | ->ordered() |
|
130 | ->where($orderColumnName, '<', $this->$orderColumnName) |
|
131 | ->first(); |
|
132 | ||
133 | if (!$swapWithModel) { |
|
134 | return false; |
|
135 | } |
|
136 | ||
137 | return $this->swapOrderWithModel($swapWithModel); |
|
138 | } |
|
139 | ||
140 | /** |
|
141 | * Swap the order of this model with the order of another model |