From 768973150450c5d6d545a63d2b1425830966738f Mon Sep 17 00:00:00 2001 From: ALIN <=> Date: Fri, 11 Apr 2025 19:55:15 +0300 Subject: [PATCH 1/5] upgraded to native enums --- database/factories/TutorialFactory.php | 2 +- src/Enums/Placement.php | 14 ++++++++------ src/Http/Resources/Tutorial.php | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) 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..35ec1cb 100644 --- a/src/Enums/Placement.php +++ b/src/Enums/Placement.php @@ -2,12 +2,14 @@ namespace LaravelEnso\Tutorials\Enums; -use LaravelEnso\Enums\Services\Enum; +use LaravelEnso\Enums\Services\Enums\Select; -class Placement extends Enum +enum Placement: int { - public const Top = 1; - public const Bottom = 2; - public const Right = 3; - public const Left = 4; + use Select as Options; + + 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, ], ]; } From 84af8bdbb6ef95a92b53efd32977f61a7aeb0c62 Mon Sep 17 00:00:00 2001 From: ALIN <=> Date: Mon, 14 Apr 2025 12:47:02 +0300 Subject: [PATCH 2/5] ajusted placement enum --- src/Enums/Placement.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Enums/Placement.php b/src/Enums/Placement.php index 35ec1cb..c8674b6 100644 --- a/src/Enums/Placement.php +++ b/src/Enums/Placement.php @@ -2,11 +2,12 @@ namespace LaravelEnso\Tutorials\Enums; -use LaravelEnso\Enums\Services\Enums\Select; +use LaravelEnso\Enums\Contracts\Select; +use LaravelEnso\Enums\Services\Enums\Select as Options; -enum Placement: int +enum Placement: int implements Select { - use Select as Options; + use Options; case Top = 1; case Bottom = 2; From 6cd2ef9f870ece29d505c78ad3e069e85f955599 Mon Sep 17 00:00:00 2001 From: ALIN <=> Date: Mon, 14 Apr 2025 18:18:01 +0300 Subject: [PATCH 3/5] ajusted enum --- src/Enums/Placement.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Enums/Placement.php b/src/Enums/Placement.php index c8674b6..3d902d4 100644 --- a/src/Enums/Placement.php +++ b/src/Enums/Placement.php @@ -3,7 +3,8 @@ namespace LaravelEnso\Tutorials\Enums; use LaravelEnso\Enums\Contracts\Select; -use LaravelEnso\Enums\Services\Enums\Select as Options; +use LaravelEnso\Enums\Traits\Select as Options; + enum Placement: int implements Select { From 0afc435e0d2bca41acd2fae9095932c2acd94aaf Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Mon, 14 Apr 2025 15:18:12 +0000 Subject: [PATCH 4/5] Apply fixes from StyleCI --- src/Enums/Placement.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Enums/Placement.php b/src/Enums/Placement.php index 3d902d4..e9c8ec0 100644 --- a/src/Enums/Placement.php +++ b/src/Enums/Placement.php @@ -5,7 +5,6 @@ use LaravelEnso\Enums\Contracts\Select; use LaravelEnso\Enums\Traits\Select as Options; - enum Placement: int implements Select { use Options; From 3072f0c92d46c97b4ef7cf00a412cd5301ab983a Mon Sep 17 00:00:00 2001 From: ALIN <=> Date: Wed, 16 Apr 2025 11:17:17 +0300 Subject: [PATCH 5/5] Adjusted enum usage --- src/Enums/Placement.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/Enums/Placement.php b/src/Enums/Placement.php index e9c8ec0..eb84b41 100644 --- a/src/Enums/Placement.php +++ b/src/Enums/Placement.php @@ -2,13 +2,8 @@ namespace LaravelEnso\Tutorials\Enums; -use LaravelEnso\Enums\Contracts\Select; -use LaravelEnso\Enums\Traits\Select as Options; - -enum Placement: int implements Select +enum Placement: int { - use Options; - case Top = 1; case Bottom = 2; case Right = 3;