Files
LarsandCursor 2035c46edd
Deploy Test / test (push) Successful in 2m25s
Deploy Test / deploy (push) Failing after 25s
Stelle das U0-Fundament mit CMS, Mitgliedern und Filament bereit.
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-15 08:32:14 +01:00

38 lines
1.1 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Domain\Identity\AssignStaffRoles;
use App\Domain\Identity\RegisterAccount;
use App\Domain\Identity\StaffRole;
use Illuminate\Console\Command;
use Illuminate\Support\Str;
class CreateStaffUser extends Command
{
protected $signature = 'luf:personal {email} {--role=systemverwalter} {--name=Personal}';
protected $description = 'Legt ein bestätigtes Personalkonto an und gibt das Passwort einmal aus';
public function handle(RegisterAccount $register, AssignStaffRoles $assign): int
{
$role = StaffRole::tryFrom((string) $this->option('role'));
if ($role === null) {
$this->error('Unbekannte Rolle.');
return self::FAILURE;
}
$password = Str::password(20);
$user = $register->register((string) $this->option('name'), (string) $this->argument('email'), $password, true);
$user->markEmailAsVerified();
$assign->sync($user, [$role->value], $user);
$this->info('Konto angelegt. Passwort (nur diese Ausgabe):');
$this->line($password);
return self::SUCCESS;
}
}