context = DatabaseConnection::i()->getContext(); $this->restores = $this->context->table("password_resets"); } function toPasswordReset(?ActiveRow $ar): ?PasswordReset { return is_null($ar) ? NULL : new PasswordReset($ar); } function getByToken(string $token): ?PasswordReset { return $this->toPasswordReset($this->restores->where("key", $token)->fetch()); } function getLatestByUser(User $user): ?PasswordReset { return $this->toPasswordReset($this->restores->where("profile", $user->getId())->order("timestamp DESC")->fetch()); } }