1 | <?php |
||
7 | class DefaultTransition extends Transition |
||
8 | { |
||
9 | protected Model $model; |
||
|
|||
10 | |||
11 | protected string $field; |
||
12 | |||
13 | protected State $newState; |
||
14 | |||
15 | public function __construct( |
||
16 | Model $model, |
||
17 | string $field, |
||
18 | State $newState |
||
19 | ) { |
||
20 | $this->model = $model; |
||
21 | $this->field = $field; |
||
22 | $this->newState = $newState; |
||
23 | } |
||
24 | |||
25 | public function handle(): Model |
||
26 | { |
||
27 | $this->model->{$this->field} = $this->newState; |
||
28 | |||
29 | $this->model->save(); |
||
30 | |||
31 | return $this->model; |
||
32 | } |
||
33 | } |
||
34 |