ask('Naam van de gebruiker'); $email = $this->ask('E-mailadres'); $password = $this->secret('Wachtwoord'); $choices = collect(UserRole::cases())->map(fn($role) => $role->label())->toArray(); $names = collect(UserRole::cases())->map(fn($role) => $role->name)->toArray(); $index = $this->choice('Welke rol?', $choices); // string zoals 'Beheerder' $name = $names[array_search($index, $choices)]; $role = UserRole::tryFromName($name); if (!$role) { $this->error("Ongeldige rol opgegeven."); return Command::FAILURE; } $user = User::create([ 'name' => $name, 'email' => $email, 'password' => Hash::make($password), 'role' => $role, ]); $this->info("Gebruiker {$user->email} aangemaakt met rol {$role->name}"); return Command::SUCCESS; } }