/** * Create a staff member * * @param array $data * @return bool * @throws CreateFailedException */ public function create(array $data) { $account = $this->account->findByName($data['account']); if (!$account) { throw new CreateFailedException('This account does not exist!'); } $player = $this->player->findByName($data['player']); if (!$player) { throw new CreateFailedException('This player does not exist!'); } return (bool) $this->staff->create($data); }
/** * Generate a new password for the user * * @param array $data * @throws \Metin2CMS\Exceptions\Core\RemindFailedException * @return mixed */ public function remind(array $data) { $account = $this->account->findByName($data['username']); if (!$account || $account['email'] !== $data['email']) { throw new RemindFailedException('Can\'t find account by the provided user and email.'); } $this->reminder->deleteByUser($data['username']); $data = ['id' => $account['id'], 'username' => $account['login'], 'email' => $account['email'], 'login' => $account['login'], 'token' => str_random(64), 'password' => str_random(10)]; $this->events->fire('account.remind.before', [$data]); $wasCreated = $this->reminder->create($data); if ($wasCreated) { $this->events->fire('account.remind.after', [$data]); } return $wasCreated; }