Skip to content

Commit

Permalink
Merge pull request #86 from amshehzad/add-contributor-fix
Browse files Browse the repository at this point in the history
Fixed issue with create contributor command
  • Loading branch information
MohmmedAshraf authored Mar 7, 2024
2 parents afe23c6 + 1e17350 commit 7574589
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Console/Commands/ContributorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand Down
8 changes: 8 additions & 0 deletions src/Enums/RoleEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7574589

Please sign in to comment.