| @@ 9-46 (lines=38) @@ | ||
| 6 | use Facade\IgnitionContracts\BaseSolution; | |
| 7 | use Facade\IgnitionContracts\ProvidesSolution; | |
| 8 | ||
| 9 | class MissingTraitOnModel extends InvalidConfig implements ProvidesSolution | |
| 10 | { | |
| 11 | /** @var string */ | |
| 12 | protected $modelClass; | |
| 13 | ||
| 14 | /** @var string */ | |
| 15 | protected $trait; | |
| 16 | ||
| 17 | public static function make(string $modelClass, string $trait): self | |
| 18 |     { | |
| 19 |         return (new static("The method `resolveTransition` was not found on model `{$modelClass}`, are you sure it uses the `{$trait} trait?`")) | |
| 20 | ->setModelClass($modelClass) | |
| 21 | ->setTrait($trait); | |
| 22 | } | |
| 23 | ||
| 24 | public function setModelClass(string $modelClass): self | |
| 25 |     { | |
| 26 | $this->modelClass = $modelClass; | |
| 27 | ||
| 28 | return $this; | |
| 29 | } | |
| 30 | ||
| 31 | public function setTrait(string $trait): self | |
| 32 |     { | |
| 33 | $this->trait = $trait; | |
| 34 | ||
| 35 | return $this; | |
| 36 | } | |
| 37 | ||
| 38 | public function getSolution(): Solution | |
| 39 |     { | |
| 40 |         return BaseSolution::create('Missing trait on model') | |
| 41 |             ->setSolutionDescription("Use the `{$this->trait}` trait on `{$this->modelClass}`") | |
| 42 | ->setDocumentationLinks([ | |
| 43 | 'Configuring states' => 'https://docs.spatie.be/laravel-model-states/v1/working-with-states/01-configuring-states/' | |
| 44 | ]); | |
| 45 | } | |
| 46 | } | |
| 47 | ||
| @@ 9-46 (lines=38) @@ | ||
| 6 | use Facade\IgnitionContracts\BaseSolution; | |
| 7 | use Facade\IgnitionContracts\ProvidesSolution; | |
| 8 | ||
| 9 | class UnknownState extends InvalidConfig implements ProvidesSolution | |
| 10 | { | |
| 11 | /** @var string */ | |
| 12 | protected $field; | |
| 13 | ||
| 14 | /** @var string */ | |
| 15 | protected $modelClass; | |
| 16 | ||
| 17 | public static function make(string $field, string $modelClass): self | |
| 18 |     { | |
| 19 |         return (new static("No state field found for {$modelClass}::{$field}, did you forget to provide a mapping in {$modelClass}::registerStates()?")) | |
| 20 | ->setField($field) | |
| 21 | ->setModelClass($modelClass); | |
| 22 | } | |
| 23 | ||
| 24 | public function setField(string $field): self | |
| 25 |     { | |
| 26 | $this->field = $field; | |
| 27 | ||
| 28 | return $this; | |
| 29 | } | |
| 30 | ||
| 31 | public function setModelClass(string $modelClass): self | |
| 32 |     { | |
| 33 | $this->modelClass = $modelClass; | |
| 34 | ||
| 35 | return $this; | |
| 36 | } | |
| 37 | ||
| 38 | public function getSolution(): Solution | |
| 39 |     { | |
| 40 |         return BaseSolution::create('The state field is unknown') | |
| 41 |             ->setSolutionDescription("Add the `{$this->field}` field to the `registerStates` method inside `{$this->modelClass}`") | |
| 42 | ->setDocumentationLinks([ | |
| 43 | 'Configuring states' => 'https://docs.spatie.be/laravel-model-states/v1/working-with-states/01-configuring-states/', | |
| 44 | ]); | |
| 45 | } | |
| 46 | } | |
| 47 | ||