request = $request; $this->account = $account; $this->company = $company; } /** * Execute the job. * * @return void */ public function handle() { $user = new User(); $user->account_id = $this->account->id; $user->password = bcrypt($this->request->input('password')); $user->accepted_terms_version = config('ninja.terms_version'); $user->confirmation_code = $this->createDbHash(config('database.default')); $user->db = config('database.default'); $user->fill($this->request->all()); $user->save(); CompanyUser::create([ 'user_id' => $user->id, 'account_id' => $this->account->id, 'company_id' => $this->company->id, 'is_admin' => true, 'is_owner' => true, 'permissions' => '', ]); event(new UserCreated($user)); return $user; } }