new NotInConstraint(TicketStatuses::CLOSED, TicketStatuses::SOLVED), "dts_deleted" => null ]); } /** * @return Location * @throws Exception */ public function getLocation(): Location { return Location::get($this->location_id); } /** * @return User * @throws Exception */ public function getCreator(): User { return User::get($this->creator_user_id); } /** * @return User|null * @throws Exception */ public function getAssignedTo(): ?User { return User::get($this->assigned_user_id); } public function getDateTimeDue(): ?CarbonImmutable { return $this->dts_due ? new CarbonImmutable($this->dts_due, "UTC") : null; } /** * @return TicketComment[] */ public function getComments(): array { return TicketComment::query(["ticket_id" => $this->id], ["sort" => "id"]); } /** * @return string * @throws Exception */ public function getDisplayCreator(): string { $creator = $this->getCreator(); return $creator->getDisplayName() . " ($creator->email)"; } /** * @return string * @throws Exception */ public function getDisplayAssignedTo(): string { $assigned_to = $this->getAssignedTo(); return $assigned_to ? $assigned_to->getDisplayName() : __("Unassigned"); } public function getDisplayStatus(): string { return TicketStatuses::enumToText($this->status); } public function getPriorityBadgeHtml(): string { return TicketPriorities::getBadgeHtml($this->priority); } public function getUrl(): string { return sprintf("/tickets/%d", $this->id); } /** * @param User $user * @return bool * @throws Exception */ public function assign(User $user): bool { $this->assigned_user_id = $user->id; return $this->commit(); } /** * @return bool * @throws Exception */ public function unassign(): bool { $this->assigned_user_id = null; return $this->commit(); } /** * @return Sale|null * @throws Exception */ public function getSale(): ?Sale { return Sale::get($this->sale_id); } /** * @return Document|null * @throws Exception */ public function getAruDocument(): ?Document { return Document::get($this->aru_document_id); } public function getTitle(): string { return __("Ticket %d - %s", $this->id, $this->subject); } }