| 1 | <?php |
||
| 9 | class TransitionNotFound extends CouldNotPerformTransition implements ProvidesSolution |
||
| 10 | { |
||
| 11 | protected string $from; |
||
|
|
|||
| 12 | |||
| 13 | protected string $to; |
||
| 14 | |||
| 15 | protected string $modelClass; |
||
| 16 | |||
| 17 | public static function make(string $from, string $to, string $modelClass): self |
||
| 18 | { |
||
| 19 | return (new static("Transition from `{$from}` to `{$to}` on model `{$modelClass}` was not found, did you forget to register it in `{$modelClass}::registerStates()`?")) |
||
| 20 | ->setFrom($from) |
||
| 21 | ->setTo($to) |
||
| 22 | ->setModelClass($modelClass); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function setFrom(string $from): self |
||
| 26 | { |
||
| 27 | $this->from = $from; |
||
| 28 | |||
| 29 | return $this; |
||
| 30 | } |
||
| 31 | |||
| 32 | public function setTo(string $to): self |
||
| 33 | { |
||
| 34 | $this->to = $to; |
||
| 35 | |||
| 36 | return $this; |
||
| 37 | } |
||
| 38 | |||
| 39 | public function setModelClass(string $modelClass): self |
||
| 40 | { |
||
| 41 | $this->modelClass = $modelClass; |
||
| 42 | |||
| 43 | return $this; |
||
| 44 | } |
||
| 45 | |||
| 46 | public function getSolution(): Solution |
||
| 47 | { |
||
| 48 | return BaseSolution::create('Transition not found') |
||
| 49 | ->setSolutionDescription("Register the transition in `{$this->modelClass}::registerStates()`") |
||
| 50 | ->setDocumentationLinks([ |
||
| 51 | 'Configuring transitions' => 'https://docs.spatie.be/laravel-model-states/v1/working-with-transitions/01-configuring-transitions/', |
||
| 52 | ]); |
||
| 53 | } |
||
| 54 | } |
||
| 55 |