ldc-crm/app/Console/Commands/UserCreate.php

50 lines
1.1 KiB
PHP
Raw Permalink Normal View History

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;
class UserCreate extends Command
{
2021-03-14 10:45:42 +01:00
2020-12-01 17:02:10 +01:00
/**
* 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 int
*/
public function handle()
{
$admin = false;
$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.');
}
}