@@ -324,11 +324,11 @@ discard block |
||
| 324 | 324 | |
| 325 | 325 | $all = Dummy::all()->sortBy('order_column'); |
| 326 | 326 | $all->values()->all(); |
| 327 | - $count = $all->where('order_column', '<=', $newPosition )->count(); |
|
| 327 | + $count = $all->where('order_column', '<=', $newPosition)->count(); |
|
| 328 | 328 | $this->assertEquals($newPosition, $count); |
| 329 | 329 | |
| 330 | 330 | $counter = 1; |
| 331 | - foreach( $all as $m ){ |
|
| 331 | + foreach ($all as $m) { |
|
| 332 | 332 | $this->assertEquals($m->order_column, $counter); |
| 333 | 333 | $counter++; |
| 334 | 334 | } |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | $this->assertEquals($originalPosition, $model->order_column); |
| 344 | 344 | $this->assertEquals($newPosition, $modelAtPosition->order_column); |
| 345 | 345 | |
| 346 | - $model = $model->moveToPosition( $newPosition ); |
|
| 346 | + $model = $model->moveToPosition($newPosition); |
|
| 347 | 347 | |
| 348 | 348 | $this->assertEquals($newPosition, $model->order_column); |
| 349 | 349 | |
@@ -352,11 +352,11 @@ discard block |
||
| 352 | 352 | |
| 353 | 353 | $all = Dummy::all()->sortBy('order_column'); |
| 354 | 354 | $all->values()->all(); |
| 355 | - $count = $all->where('order_column', '<=', $newPosition )->count(); |
|
| 355 | + $count = $all->where('order_column', '<=', $newPosition)->count(); |
|
| 356 | 356 | $this->assertEquals($newPosition, $count); |
| 357 | 357 | |
| 358 | 358 | $counter = 1; |
| 359 | - foreach( $all as $m ){ |
|
| 359 | + foreach ($all as $m) { |
|
| 360 | 360 | $this->assertEquals($m->order_column, $counter); |
| 361 | 361 | $counter++; |
| 362 | 362 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | { |
| 12 | 12 | public static function bootSortableTrait() |
| 13 | 13 | { |
| 14 | - static::creating(function ($model) { |
|
| 14 | + static::creating(function($model) { |
|
| 15 | 15 | if ($model instanceof Sortable && $model->shouldSortWhenCreating()) { |
| 16 | 16 | $model->setHighestOrderNumber(); |
| 17 | 17 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | public function getOrderNumberAtPosition(int $position): int |
| 47 | 47 | { |
| 48 | 48 | $position--; |
| 49 | - $position = max($position,0); |
|
| 49 | + $position = max($position, 0); |
|
| 50 | 50 | |
| 51 | 51 | return (int) $this->buildSortQuery()->orderBy($this->determineOrderColumnName())->skip($position)->limit(1)->value($this->determineOrderColumnName()); |
| 52 | 52 | } |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | */ |
| 76 | 76 | public static function setNewOrder($ids, int $startOrder = 1) |
| 77 | 77 | { |
| 78 | - if (! is_array($ids) && ! $ids instanceof ArrayAccess) { |
|
| 78 | + if (!is_array($ids) && !$ids instanceof ArrayAccess) { |
|
| 79 | 79 | throw new InvalidArgumentException('You must pass an array or ArrayAccess object to setNewOrder'); |
| 80 | 80 | } |
| 81 | 81 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | { |
| 99 | 99 | if ( |
| 100 | 100 | isset($this->sortable['order_column_name']) && |
| 101 | - ! empty($this->sortable['order_column_name']) |
|
| 101 | + !empty($this->sortable['order_column_name']) |
|
| 102 | 102 | ) { |
| 103 | 103 | return $this->sortable['order_column_name']; |
| 104 | 104 | } |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | ->where($orderColumnName, '>', $this->$orderColumnName) |
| 129 | 129 | ->first(); |
| 130 | 130 | |
| 131 | - if (! $swapWithModel) { |
|
| 131 | + if (!$swapWithModel) { |
|
| 132 | 132 | return $this; |
| 133 | 133 | } |
| 134 | 134 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | ->where($orderColumnName, '<', $this->$orderColumnName) |
| 150 | 150 | ->first(); |
| 151 | 151 | |
| 152 | - if (! $swapWithModel) { |
|
| 152 | + if (!$swapWithModel) { |
|
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | * |
| 250 | 250 | * @return $this |
| 251 | 251 | */ |
| 252 | - public function moveToPosition( int $newPosition ): self |
|
| 252 | + public function moveToPosition(int $newPosition): self |
|
| 253 | 253 | { |
| 254 | 254 | $orderColumnName = $this->determineOrderColumnName(); |
| 255 | 255 | |
@@ -259,11 +259,11 @@ discard block |
||
| 259 | 259 | $orderAtPosition = $this->getOrderNumberAtPosition($newPosition); |
| 260 | 260 | |
| 261 | 261 | // No need to do anything, it is already in the correct position |
| 262 | - if ($currentPosition === $newPosition){ |
|
| 262 | + if ($currentPosition === $newPosition) { |
|
| 263 | 263 | return $this; |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - if ( $newPosition > $currentPosition ){ |
|
| 266 | + if ($newPosition > $currentPosition) { |
|
| 267 | 267 | // The model is moving up |
| 268 | 268 | $this->buildSortQuery()->where([[$this->getKeyName(), '!=', $this->id], [$orderColumnName, '>', $currentPosition], [$orderColumnName, '<=', $orderAtPosition]])->decrement($orderColumnName); |
| 269 | 269 | } else { |