From af1109c87377f88109574c05cd0b828d46d319da Mon Sep 17 00:00:00 2001 From: Maicol Battistini Date: Wed, 6 Dec 2023 21:29:47 +0100 Subject: [PATCH] refactor: Refactor della creazione di un utente Admin usando l'azione di Fortify --- app/Console/Commands/CreateAdminUserCommand.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/CreateAdminUserCommand.php b/app/Console/Commands/CreateAdminUserCommand.php index 303acc8ed..9c16f668f 100644 --- a/app/Console/Commands/CreateAdminUserCommand.php +++ b/app/Console/Commands/CreateAdminUserCommand.php @@ -2,6 +2,7 @@ namespace App\Console\Commands; +use App\Actions\Fortify\CreateNewUser; use App\Models\User; use Illuminate\Console\Command; use Illuminate\Support\Str; @@ -20,16 +21,13 @@ class CreateAdminUserCommand extends Command $username = text('Username', required: true); $email = text('Email', required: true); $password = password('Password', required: true); + $password_confirmation = password('Confirm Password', required: true); $this->table(['Username', 'Email', 'Password'], [[$username, $email, '********']]); if (confirm('Are you sure you want to create this user?')) { - $user = new User(); - $user->username = $username; - $user->email = $email; - $user->password = $password; + $user = app(CreateNewUser::class)->create(compact('username', 'email', 'password', 'password_confirmation')); $user->email_verified_at = now(); - $user->remember_token = Str::random(10); $user->save(); $this->info('Admin user created successfully');