ldc-com-app-bo/app/Console/Commands/UserCreate.php

55 lines
1.1 KiB
PHP
Raw Normal View History

2021-01-15 14:47:59 +01:00
<?php
namespace App\Console\Commands;
use App\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
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 = 'Create admin account';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
2022-09-29 10:09:43 +02:00
* @return integer
2021-01-15 14:47:59 +01:00
*/
public function handle()
{
2022-09-29 10:09:43 +02:00
$name = $this->ask('What is the name?');
2021-01-15 14:47:59 +01:00
$email = $this->ask('What is the mail?');
2022-09-29 10:09:43 +02:00
$pwd = $this->secret('What is the password?');
2021-01-15 14:47:59 +01:00
2022-09-29 10:09:43 +02:00
$user = new User();
$user->name = $name;
$user->email = $email;
2021-01-15 14:47:59 +01:00
$user->password = Hash::make($pwd);
$user->save();
$this->info('User created.');
}
}