diff --git a/src/app/Console/Commands/CreateUser.php b/src/app/Console/Commands/CreateUser.php new file mode 100644 index 0000000..3858ccd --- /dev/null +++ b/src/app/Console/Commands/CreateUser.php @@ -0,0 +1,62 @@ +option('email')); + + $name = $this->ask("Please provide a name"); + $surname = $this->ask("Please provide a surname"); + + if (empty($email)) { + $email = $this->ask("Please provide an email address"); + } + + if (empty($password)) { + // TODO: have a way to hide the input and do a confirm password input + $password = $this->ask("Please provide a password"); + } + + try { + User::create([ + 'name' => trim($name), + 'surname' => trim($surname), + 'email' => trim($email), + 'password' => Hash::make(trim($password)), + ]); + + $this->info("$email created successfully."); + return 0; + } catch (\Exception $e) { + $this->error('Unable to create your user.'); + $this->line($e->getMessage()); + return 1; + } + } +}