/**
  * 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);
 }
Example #2
0
 /**
  * After Update method
  *
  * Triggers mail sender on update.
  */
 public function afterUpdate()
 {
     $mailer = new SupportMailer();
     $email = $this->creator->email;
     $address = Settings::get('address');
     $vars = ['ticket_number' => $this->hash_id, 'ticket_link' => $address . '/' . $this->hash_id, 'ticket_status' => $this->status->name];
     if ($this->status == 'Closed' || $this->status == 'Resolved') {
         $mailer->sendAfterTicketClosed($email, $vars);
     } else {
         if ($this->is_support == 1) {
             $mailer->sendAfterTicketUpdated($email, $vars);
         }
     }
 }