58 lines
1.1 KiB
PHP
58 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Repositories\UserRepository;
|
|
use Illuminate\Console\Command;
|
|
use App\User;
|
|
use Hash;
|
|
use Str;
|
|
|
|
class CreateEditorAccount extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'account:create-editor {email} {password}';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Create an editor account';
|
|
|
|
/**
|
|
* Create a new command instance.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
$email = $this->argument('email');
|
|
$password = $this->argument('password');
|
|
|
|
$user = User::create([
|
|
'email' => $email,
|
|
'password' => Hash::make($password),
|
|
'api_token' => Str::random(36)
|
|
]);
|
|
|
|
$user->assignRole('editor');
|
|
|
|
$this->info("Account: $email has been created");
|
|
}
|
|
}
|