49 lines
1 KiB
PHP
49 lines
1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Console\Command;
|
|
|
|
/**
|
|
* @codeCoverageIgnore
|
|
*/
|
|
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.
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function handle()
|
|
{
|
|
$firstname = $this->ask('What is the firstname?');
|
|
$lastname = $this->ask('What is the lastname?');
|
|
$email = $this->ask('What is the email?');
|
|
$pwd = $this->secret('What is the password?');
|
|
|
|
$user = new User();
|
|
$user->firstname = $firstname;
|
|
$user->lastname = $lastname;
|
|
$user->email = $email;
|
|
$user->password = $pwd;
|
|
$user->saveOrFail();
|
|
|
|
$this->info('User created.');
|
|
return 0;
|
|
}
|
|
}
|