| @@ 79-86 (lines=8) @@ | ||
| 76 | */ |
|
| 77 | public function toFirst(Model $model) |
|
| 78 | { |
|
| 79 | if ($model->{$this->column} != 1) { |
|
| 80 | $models = $model::where($this->column, '<', $model->{$this->column})->get(); |
|
| 81 | $models->each->increment($this->column); |
|
| 82 | $model->{$this->column} = 1; |
|
| 83 | $model->save(); |
|
| 84 | ||
| 85 | return true; |
|
| 86 | } |
|
| 87 | ||
| 88 | return false; |
|
| 89 | } |
|
| @@ 100-107 (lines=8) @@ | ||
| 97 | { |
|
| 98 | $last = $this->count($model); |
|
| 99 | ||
| 100 | if ($last != $model->{$this->column}) { |
|
| 101 | $models = $model::where($this->column, '>', $model->{$this->column})->get(); |
|
| 102 | $models->each->decrement($this->column); |
|
| 103 | $model->{$this->column} = $last; |
|
| 104 | $model->save(); |
|
| 105 | ||
| 106 | return true; |
|
| 107 | } |
|
| 108 | ||
| 109 | return false; |
|
| 110 | } |
|