2020-12-01 17:02:10 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
|
|
use App\Models\User;
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
|
use Illuminate\Support\Facades\Hash;
|
|
|
|
|
|
2021-12-19 15:57:24 +01:00
|
|
|
/**
|
|
|
|
|
* @codeCoverageIgnore
|
|
|
|
|
*/
|
2020-12-01 17:02:10 +01:00
|
|
|
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 = 'Command description';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the console command.
|
|
|
|
|
*
|
2021-12-19 15:57:24 +01:00
|
|
|
* @return integer
|
2020-12-01 17:02:10 +01:00
|
|
|
*/
|
|
|
|
|
public function handle()
|
|
|
|
|
{
|
|
|
|
|
$firstname = $this->ask('What is the firstname?');
|
2021-03-14 10:45:42 +01:00
|
|
|
$lastname = $this->ask('What is the lastname?');
|
|
|
|
|
$email = $this->ask('What is the email?');
|
|
|
|
|
$pwd = $this->secret('What is the password?');
|
2020-12-01 17:02:10 +01:00
|
|
|
|
2021-03-14 10:45:42 +01:00
|
|
|
$user = new User();
|
2020-12-01 17:02:10 +01:00
|
|
|
$user->firstname = $firstname;
|
2021-03-14 10:45:42 +01:00
|
|
|
$user->lastname = $lastname;
|
|
|
|
|
$user->email = $email;
|
|
|
|
|
$user->password = Hash::make($pwd);
|
2020-12-01 17:02:10 +01:00
|
|
|
$user->save();
|
|
|
|
|
|
|
|
|
|
$this->info('User created.');
|
2021-12-19 15:57:24 +01:00
|
|
|
return 0;
|
2020-12-01 17:02:10 +01:00
|
|
|
}
|
|
|
|
|
}
|