ldc-portsalaries/app/Console/Commands/AdminCreate.php

49 lines
934 B
PHP
Raw Permalink Normal View History

2021-07-08 14:05:50 +02:00
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
2021-07-08 14:05:50 +02:00
class AdminCreate extends Command
{
2021-07-08 14:05:50 +02:00
/**
* 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 int
*/
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' => $password
]);
$user->saveOrFail();
$this->info('Admin created.');
return 0;
}
}