diff --git a/database/factories/TutorialFactory.php b/database/factories/TutorialFactory.php index 0d08a21..8e1c1ad 100644 --- a/database/factories/TutorialFactory.php +++ b/database/factories/TutorialFactory.php @@ -18,7 +18,7 @@ public function definition() 'element' => $this->faker->word, 'title' => $this->faker->word, 'content' => $this->faker->sentence, - 'placement' => Placement::keys()->random(), + 'placement' => $this->faker->randomElement(Placement::cases())->value, 'order_index' => $this->faker->randomNumber(2), ]; } diff --git a/src/Enums/Placement.php b/src/Enums/Placement.php index 288d5e1..eb84b41 100644 --- a/src/Enums/Placement.php +++ b/src/Enums/Placement.php @@ -2,12 +2,10 @@ namespace LaravelEnso\Tutorials\Enums; -use LaravelEnso\Enums\Services\Enum; - -class Placement extends Enum +enum Placement: int { - public const Top = 1; - public const Bottom = 2; - public const Right = 3; - public const Left = 4; + case Top = 1; + case Bottom = 2; + case Right = 3; + case Left = 4; } diff --git a/src/Http/Resources/Tutorial.php b/src/Http/Resources/Tutorial.php index e264cda..7ce87fd 100644 --- a/src/Http/Resources/Tutorial.php +++ b/src/Http/Resources/Tutorial.php @@ -14,7 +14,7 @@ public function toArray($request) 'popover' => [ 'title' => __($this->title), 'description' => __($this->content), - 'position' => Placement::get($this->placement), + 'position' => Placement::from($this->placement)->name, ], ]; }