Keystore/app/Console/Commands/CreateUser.php
Helge-Mikael Nordgård a6a0a0a506 first commit
2025-02-05 03:05:01 +01:00

55 lines
1.2 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
class CreateUser extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:create-user';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Oppretter en bruker i systemet';
/**
* Execute the console command.
*/
public function handle() {
$name = $this->ask('Oppgi brukerens fulle navn');
$username = $this->ask('Oppgi brukerens epost-adresse');
$password = $this->secret('Oppgi et passord');
$this->newLine();
$this->line('Bekreft følgende detaljer:');
$this->line('Navn: ' . $name);
$this->line('Brukernavn: ' . $username);
$this->line('Passord: <hidden>');
$this->newLine(2);
if ($this->confirm('Ønsker du å fortsette?')) {
$user = User::create([
'name' => $name,
'email' => $username,
'password' => bcrypt($password)
]);
$this->newLine();
$this->info('Ny bruker opprettet!');
}
}
}