新增建立editor帳號的指令
This commit is contained in:
parent
13d66e9522
commit
dee8c07bc0
57
app/Console/Commands/CreateEditorAccount.php
Normal file
57
app/Console/Commands/CreateEditorAccount.php
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?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");
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user