ticket_id); } /** * @return User * @throws Exception */ public function getUser(): User { return User::get($this->user_id); } public function getDateTime(): CarbonImmutable { return new CarbonImmutable($this->dts_created, "UTC"); } /** * @return TicketCommentAttachment[] */ public function getAttachments(): array { return TicketCommentAttachment::query([ "ticket_comment_id" => $this->id, ], [ "sort" => "id", "order" => "desc" ]); } public function getHtml(): string { return nl2br(htmlspecialchars($this->content)); } public function getDisplayDateTimeCreated(): string { return $this->getDateTime()->format("d/m/Y H:i"); } /** * @param array $form_file * @return TicketCommentAttachment * @throws Exception */ public function addAttachment(array $form_file): TicketCommentAttachment { $attachment = new TicketCommentAttachment(); $attachment->ticket_comment_id = $this->id; $attachment->mime_type = $form_file["type"]; $attachment->file_name = $form_file["name"]; $attachment->file_size = $form_file["size"]; $attachment->commit(); $path = $attachment->getPath(); move_uploaded_file($form_file["tmp_name"], $path); return $attachment; } }