/**
  * Creates new Ticket and redirects to its page
  *
  * @return \Illuminate\Http\RedirectResponse
  * @throws \ValidationException
  */
 public function onTicketCreate()
 {
     $data = post();
     $this->helpers->validateTicket($data);
     $creator = \Auth::getUser();
     $ticketPage = Settings::get('address');
     $newStatus = TicketStatus::where('name', 'New')->first()->id;
     $content = $this->purifyTicket($data['content']);
     $ticket = new Ticket();
     $ticket->hash_id = 'temp';
     $ticket->category_id = $data['category'];
     $ticket->creator_id = $creator->id;
     $ticket->email = $creator->email;
     $ticket->website = $data['website'];
     $ticket->topic = $data['topic'];
     $ticket->content = $content;
     $ticket->status = $newStatus;
     $ticket->save();
     $hashId = $this->helpers->generateHashId($ticket->id);
     $ticket->hash_id = $hashId;
     $ticket->save();
     $this->page['hash_id'] = $hashId;
     $this->helpers->newTicketHandler($hashId);
     $mailer = new SupportMailer();
     $address = Settings::get('address');
     $vars = ['ticket_number' => $ticket->hash_id, 'ticket_link' => $address . '/' . $ticket->hash_id];
     $mailer->sendAfterTicketCreated($creator->email, $vars);
     return \Redirect::to($ticketPage . $hashId);
 }
 /**
  * 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;
 }
Beispiel #3
0
 /**
  * Deletes checked tickets.
  */
 public function index_onDelete()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $ticketId) {
             if (!($ticket = Ticket::find($ticketId))) {
                 continue;
             }
             $ticket->delete();
         }
         Flash::success(Lang::get('keios.support::lang.tickets.delete_selected_success'));
     } else {
         Flash::error(Lang::get('keios.support::lang.tickets.delete_selected_empty'));
     }
     return $this->listRefresh();
 }
 /**
  * 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;
 }