diff --git a/src/Console/Commands/ContributorCommand.php b/src/Console/Commands/ContributorCommand.php index 940e0e4..8e4df69 100644 --- a/src/Console/Commands/ContributorCommand.php +++ b/src/Console/Commands/ContributorCommand.php @@ -54,10 +54,10 @@ protected function interact(InputInterface $input, OutputInterface $output): voi $input->setArgument('role', select( label: 'What role should the contributor have?', options: [ - RoleEnum::owner->value => RoleEnum::owner->label(), - RoleEnum::translator->value => RoleEnum::translator->label(), + RoleEnum::owner->label() => RoleEnum::owner->label(), + RoleEnum::translator->label() => RoleEnum::translator->label(), ], - default: 'Owner', + default: RoleEnum::owner->label(), hint: 'The role may be changed at any time.' )); } @@ -86,7 +86,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int fn () => Contributor::create([ 'name' => $name, 'email' => $email, - 'role' => RoleEnum::fromLabel($role) ?? RoleEnum::owner->value, + 'role' => RoleEnum::fromLabel($role), 'password' => Hash::make($password), ]), 'Creating contributor...' diff --git a/src/Enums/RoleEnum.php b/src/Enums/RoleEnum.php index 124565c..ebe2d5e 100644 --- a/src/Enums/RoleEnum.php +++ b/src/Enums/RoleEnum.php @@ -18,8 +18,9 @@ public function label(): string public static function fromLabel($label): self { return match ($label) { - 'Owner' => self::owner, - 'Translator' => self::translator, + 'Owner', 'owner' => self::owner, + 'Translator', 'translator' => self::translator, + default => self::owner, }; }