/** * 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); }
/** * Deletes checked ticket statuses. */ public function index_onDelete() { if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) { foreach ($checkedIds as $ticketstatusId) { if (!($ticketstatus = TicketStatus::find($ticketstatusId))) { continue; } $ticketstatus->delete(); } Flash::success(Lang::get('keios.support::lang.ticketstatuses.delete_selected_success')); } else { Flash::error(Lang::get('keios.support::lang.ticketstatuses.delete_selected_empty')); } return $this->listRefresh(); }
/** * Before Update method * * Changes from new to assigned if detects assigned user */ public function beforeUpdate() { $user = $this->user_id; $statusId = $this->status->id; $newStatus = TicketStatus::where('name', 'New')->first()->id; $assignedStatus = TicketStatus::where('name', 'Assigned')->first()->id; if ($user != null && $statusId == $newStatus) { $this->status_id = $assignedStatus; } }