ldc-boutique-cnc/app/Console/Commands/CreateAdmin.php
Olivier Legat 8d71046626 gestion des prix pour articles facturé au poids et vendu à la pièce
(necessite la gestion stricte des unités de vente)
2021-09-02 12:34:43 +02:00

59 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
class CreateAdmin extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'create:admin';
/**
* The console command description.
*
* @var string
*/
protected $description = 'creates an admin user upon password entry';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
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?');
$user = new User();
$user->firstname = $firstname;
$user->lastname = $lastname;
$user->date_of_birth = now();
$user->email = $email;
$user->password = Hash::make($pwd);
$user->email_verified_at = now();
$user->role = 1;
$user->save();
$this->info('User created.');
}
}