diff --git a/src/Console/Commands/ContributorCommand.php b/src/Console/Commands/ContributorCommand.php index c0eedec..940e0e4 100644 --- a/src/Console/Commands/ContributorCommand.php +++ b/src/Console/Commands/ContributorCommand.php @@ -86,7 +86,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) {