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