/** * @return void */ public function handle() { $password = (string) new RandomPassword(); $hasher = new Hasher(); try { $person = Person::create(['name' => $this->name, 'email' => $this->email, 'password' => $hasher->make($password)]); } catch (DuplicateEmailException $e) { } if (isset($person)) { Event::fire(new AccountCreated($person, $password, Auth::user())); return $person; } else { return Person::findByEmail($this->email); } }
/** * @return void */ public function handle() { $password = (string) new RandomPassword(); $this->credentials['password'] = Auth::hash($password); try { $person = Person::create($this->credentials); } catch (DuplicateEmailException $e) { } if (isset($person)) { foreach ($this->groups as $groupId) { $person->addGroup(Group::find($groupId)); } Event::fire(new AccountCreated($person, $password, Auth::getPerson())); return $person; } else { return Person::findByEmail($this->credentials['email']); } }