ldc-boutique-cnc-sable/app/Console/Commands/UserCreate.php
2023-07-28 07:25:36 +00:00

49 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
class UserCreate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'user:create';
/**
* The console command description.
*
* @var string
*/
protected $description = 'creates an admin user upon password entry';
/**
* Execute the console command.
*
* @return void
*/
public function handle()
{
$firstname = $this->ask('What is the firstname?', 'Equipe');
$lastname = $this->ask('What is the lastname?', 'Web');
$email = $this->ask('What is the email?', 'equipe.web@ldc.fr');
$pwd = $this->secret('What is the password?');
$role = $this->ask('What is the role? (1 = SuperAdmin, 2 = Admin)', 2);
$user = new User();
$user->firstname = $firstname;
$user->lastname = $lastname;
$user->email = $email;
$user->password = Hash::make($pwd);
$user->email_verified_at = now();
$user->role = $role;
$user->save();
$this->info('User created.');
}
}