REBELinBLUE\Deployer\Console\Commands\CreateUser::handle PHP Метод

handle() публичный Метод

Execute the console command.
public handle ( )
    public function handle()
    {
        $arguments = $this->argument();
        $send_email = !$this->option('no-email');
        $password_generated = false;
        if (!$arguments['password']) {
            $arguments['password'] = str_random(15);
            $password_generated = true;
        }
        $validator = Validator::make($arguments, ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users,email', 'password' => 'required|min:6']);
        if (!$validator->passes()) {
            throw new RuntimeException($validator->errors()->first());
        }
        $user = $this->repository->create($arguments);
        $message = 'The user has been created';
        if ($send_email) {
            $message = 'The user has been created and their account details have been emailed to ' . $user->email;
            event(new UserWasCreated($user, $arguments['password']));
        } elseif ($password_generated) {
            $message .= ', however you elected to not email the account details to them. ';
            $message .= 'Their password is ' . $arguments['password'];
        }
        $this->info($message);
    }