ldc-gen-game-web/app/Console/Commands/CreateAdmin.php
Jérémy Munsch 1af96897f3
- Squash migration
- Normalize Model names and sql tables
- PHPCS clean up
- Change analytics form + field
2022-01-11 12:46:10 +01:00

57 lines
1.5 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 = 'Command description';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$firstname = $this->ask('What is the firstname?', 'Informatique');
$lastname = $this->ask('What is the lastname?', 'Internet');
$email = $this->ask('What is the email?', 'equipe.web@ldc.fr');
$pwd = $this->secret('What is the password?');
$role = $this->ask('Role ?', '1');
$user = new User();
$user->firstname = $firstname;
$user->lastname = $lastname;
$user->birth_date = now();
$user->email = $email;
$user->password = Hash::make($pwd);
$user->address = "-";
$user->town = "Le Mans";
$user->postal_code = "72000";
$user->country = "France";
$user->email_verify_token = "-";
$user->email_verified = 1;
$user->role = $role;
$user->save();
$this->info('User created.');
return 0;
}
}