ldc-doux/app/Console/Commands/AdminCreate.php
2022-08-11 12:34:27 +02:00

48 lines
997 B
PHP

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
use App\Models\User;
class AdminCreate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'admin:create';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create Admin User';
/**
* Execute the console command.
*
* @return integer
*/
public function handle()
{
$role = 0;
$name = $this->ask('Name ?');
$email = $this->ask('Email ?');
$password = $this->secret('What is the password?');
$user = new User([
'name' => $name,
'email' => $email,
'role' => $role,
'password' => Hash::make($password)
]);
$user->saveOrFail();
$this->info('Admin created.');
return 0;
}
}