diff --git a/src/Console/Commands/ContributorCommand.php b/src/Console/Commands/ContributorCommand.php index a201869..586457a 100644 --- a/src/Console/Commands/ContributorCommand.php +++ b/src/Console/Commands/ContributorCommand.php @@ -85,7 +85,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int fn () => Contributor::create([ 'name' => $name, 'email' => $email, - 'role' => $role ?? RoleEnum::owner->value, + 'role' => RoleEnum::fromLabel($role) ?? RoleEnum::owner->value, 'password' => Hash::make($password), ]), 'Creating contributor...' diff --git a/src/Enums/RoleEnum.php b/src/Enums/RoleEnum.php index a6ed5ea..124565c 100644 --- a/src/Enums/RoleEnum.php +++ b/src/Enums/RoleEnum.php @@ -15,6 +15,14 @@ public function label(): string }; } + public static function fromLabel($label): self + { + return match ($label) { + 'Owner' => self::owner, + 'Translator' => self::translator, + }; + } + public function description(): string { return match ($this) { diff --git a/src/Exceptions/TranslationsUIExceptionHandler.php b/src/Exceptions/TranslationsUIExceptionHandler.php index 0d29d2d..78199a2 100644 --- a/src/Exceptions/TranslationsUIExceptionHandler.php +++ b/src/Exceptions/TranslationsUIExceptionHandler.php @@ -2,8 +2,8 @@ namespace Outhebox\TranslationsUI\Exceptions; -use Illuminate\Foundation\Exceptions\Handler as BaseHandler; use App\Exceptions\Handler; +use Illuminate\Foundation\Exceptions\Handler as BaseHandler; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -18,7 +18,8 @@ class ExtendedHandler extends Handler // Extend the custom handler } } else { - class ExtendedHandler extends BaseHandler { + class ExtendedHandler extends BaseHandler + { // Extend the default handler } }