rename and translate CLI command for admin create

This commit is contained in:
Veronika Fehérvíziová
2025-12-02 19:10:13 +01:00
parent 6902eadef5
commit 687018e0fe

View File

@@ -13,50 +13,49 @@ class CreateAdmin extends Command
* *
* @var string * @var string
*/ */
protected $signature = 'user:create-garant'; protected $signature = 'app:create-admin';
/** /**
* The console command description. * The console command description.
* *
* @var string * @var string
*/ */
protected $description = 'Interaktívne vytvorí nového používateľa s rolou admin (garant)'; protected $description = 'Create a new admin user';
/** /**
* Execute the console command. * Execute the console command.
*/ */
public function handle() public function handle()
{ {
$this->info('=== Vytvorenie garanta (admin) ==='); $this->info('=== Create Admin ===');
// Načítanie údajov interaktívne // Načítanie údajov interaktívne
$firstName = $this->ask('Zadaj krstné meno'); $firstName = $this->ask('First name');
$lastName = $this->ask('Zadaj priezvisko'); $lastName = $this->ask('Last name');
$email = $this->ask('Zadaj email'); $email = $this->ask('E-mail');
// Kontrola duplicity emailu // Kontrola duplicity emailu
if (User::where('email', $email)->exists()) { if (User::where('email', $email)->exists()) {
$this->error('Používateľ s týmto emailom už existuje.'); $this->error('A user with the same email already exists.');
return 1; return 1;
} }
$password = $this->secret('Zadaj heslo (nebude sa zobrazovať)'); $password = $this->secret('Enter password');
$phone = $this->ask('Zadaj telefón '); $phone = $this->ask('Enter phone number');
// Vytvorenie používateľa // Vytvorenie používateľa
$user = User::create([ $user = User::create([
'name' => $firstName . ' ' . $lastName, 'name' => $firstName . ' ' . $lastName,
'first_name' => $firstName, 'first_name' => $firstName,
'last_name' => $lastName, 'last_name' => $lastName,
'email' => $email, 'email' => $email,
'phone' => $phone, 'password' => Hash::make($password),
'role' => 'ADMIN', 'active' => true,
'password' => Hash::make($password), 'role' => 'ADMIN',
'phone' => $phone,
]); ]);
$this->info("\n Garant {$user->first_name} {$user->last_name} bol úspešne vytvorený s rolou ADMIN."); $this->info("\n Admin {$user->first_name} {$user->last_name} created.");
$this->info("Email: {$user->email}");
return 0; return 0;
} }
} }