Skip to content

upgraded to native enums #25

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion database/factories/TutorialFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
];
}
Expand Down
12 changes: 5 additions & 7 deletions src/Enums/Placement.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/Http/Resources/Tutorial.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
],
];
}
Expand Down