| @@ 63-70 (lines=8) @@ | ||
| 60 | */ |
|
| 61 | public function toFirst(Model $model) |
|
| 62 | { |
|
| 63 | if ($model->{$this->column} != 1) { |
|
| 64 | $models = $model::where($this->column, '<', $model->{$this->column})->get(); |
|
| 65 | $models->each->increment($this->column); |
|
| 66 | $model->{$this->column} = 1; |
|
| 67 | $model->save(); |
|
| 68 | ||
| 69 | return true; |
|
| 70 | } |
|
| 71 | ||
| 72 | return false; |
|
| 73 | } |
|
| @@ 84-91 (lines=8) @@ | ||
| 81 | { |
|
| 82 | $last = $this->count($model); |
|
| 83 | ||
| 84 | if ($last != $model->{$this->column}) { |
|
| 85 | $models = $model::where($this->column, '>', $model->{$this->column})->get(); |
|
| 86 | $models->each->decrement($this->column); |
|
| 87 | $model->{$this->column} = $last; |
|
| 88 | $model->save(); |
|
| 89 | ||
| 90 | return true; |
|
| 91 | } |
|
| 92 | ||
| 93 | return false; |
|
| 94 | } |
|