/** * Loads users tickets */ public function onRun() { $creator = \Auth::getUser(); $url = Settings::get('address'); $tickets = Ticket::where('creator_id', $creator->id)->get(); $this->page['ticket_page'] = $url; $this->page['tickets'] = $tickets; }
/** * Adds comment to the ticket * * @throws \ValidationException */ public function onAddComment() { $data = post(); $this->validateComment($data); $hash = $this->property('slug'); if (!$hash && array_key_exists('ticket_number', $data)) { $hash = $data['ticket_number']; } $ticket = Ticket::where('hash_id', $hash)->first(); $author = $ticket->creator->first_name . ' ' . $ticket->creator->last_name; $authorEmail = ' (' . $ticket->creator->email . ')'; $commentContent = $this->purifyComment($data['comment_content']); $comment = new TicketComment(['author' => $author . $authorEmail, 'is_support' => 0, 'content' => $commentContent]); $ticket->comments()->save($comment); $comment->save(); $this->page['ticket'] = $ticket; }