From b2b8c9f99c63c41ddc28a67f56a10e7a866a40e9 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Sun, 24 Jan 2021 15:43:37 -0700 Subject: [PATCH] Update UserCreate command, closes #2581 --- app/Console/Commands/UserCreate.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/app/Console/Commands/UserCreate.php b/app/Console/Commands/UserCreate.php index 0945aff1d..6bae0cb57 100644 --- a/app/Console/Commands/UserCreate.php +++ b/app/Console/Commands/UserCreate.php @@ -12,7 +12,7 @@ class UserCreate extends Command * * @var string */ - protected $signature = 'user:create'; + protected $signature = 'user:create {--name=} {--username=} {--email=} {--password=} {--is_admin=0} {--confirm_email=0}'; /** * The console command description. @@ -40,6 +40,26 @@ class UserCreate extends Command { $this->info('Creating a new user...'); + $o = $this->options(); + + if( $o['name'] && + $o['username'] && + $o['email'] && + $o['password'] + ) { + $user = new User; + $user->username = $o['username']; + $user->name = $o['name']; + $user->email = $o['email']; + $user->password = bcrypt($o['password']); + $user->is_admin = (bool) $o['is_admin']; + $user->email_verified_at = (bool) $o['confirm_email'] ? now() : null; + $user->save(); + + $this->info('Successfully created user!'); + return; + } + $name = $this->ask('Name'); $username = $this->ask('Username');