/** *This function will create new tickets * * Take Post Requsets and save them in the database * Task * 1. Create new tickets * * @return View **/ public function inputs() { $user = Session::get('user'); if (is_null($user)) { return Redirect::to('login'); } if (Request::get('options') == "custom") { $heading = Request::get('heading'); } else { $heading = Request::get('options'); } $ticket = new tickets(); $ticket->userid = Session::get('userid'); $ticket->subject = $heading; $ticket->opened = 1; $ticket->save(); $ticketMsg = new tickets_messages(); $ticketMsg->user_id = Session::get('userid'); $ticketMsg->message = Request::get('txtarea'); $ticketMsg->ticket_id = $ticket->id; $ticketMsg->save(); //return view('user.tickets.new-ticket')->with('user',$user)->with('created',1); return redirect('view-ticket'); //return 1; }
/** * * Get the Tickets Reply * @param String $message Ticket body * @param Integer $ticketId Ticket ID * @return Json Response * */ private function replyTickets($message, $ticket_id) { $user = Session::get('user'); if (!is_null(trim($message)) && !is_null($ticket_id)) { $ticket = tickets::find($ticket_id); if (is_null($ticket)) { return response()->json(['message' => 'Invalid Request', 'code' => 'error']); } if ($ticket->userid != Session::get('userid') && $user->level < 10 || $ticket->opened == 0) { return response()->json(['message' => 'Invalid Request', 'code' => 'error']); } $ticketMsg = new tickets_messages(); $ticketMsg->user_id = Session::get('userid'); $ticketMsg->message = $message; $ticketMsg->ticket_id = $ticket->id; $ticketMsg->save(); return response()->json(['code' => 'success', 'task' => 'replyTickets', 'msg' => $ticketMsg]); } else { return response()->json(['message' => 'Invalid Request', 'code' => 'error']); } return response()->json(['message' => 'Invalid Request', 'code' => 'error']); }
/** * * Get the Tickets Reply * @param String $message Ticket body * @param Integer $ticketId Ticket ID * @return Json Response * */ private function replyTickets($message, $ticketId) { $user = Session::get('user'); $count = adminUserTickets::where('ticketid', $ticketId)->count(); if ($count == 0) { $adminUt = new adminUserTickets(); $adminUt->ticketid = $ticketId; $adminUt->adminid = $user->id; $adminUt->save(); } else { $count = adminUserTickets::where('adminid', $user->id)->where('ticketid', $ticketId)->count(); if ($count == 0) { return response()->json(['message' => 'Invalid Request', 'code' => 'error']); } } if (!is_null(trim($message)) && !is_null($ticketId)) { $ticket = tickets::find($ticketId); if (is_null($ticket)) { return response()->json(['message' => 'Invalid Request', 'code' => 'error']); } if ($ticket->opened == 0) { return response()->json(['message' => 'Ticket Should be opened', 'code' => 'error']); } $ticketMsg = new tickets_messages(); $ticketMsg->user_id = Session::get('userid'); $ticketMsg->message = $message; $ticketMsg->ticket_id = $ticket->id; $ticketMsg->save(); return response()->json(['code' => 'success', 'task' => 'replyTickets', 'msg' => $ticketMsg]); } else { return response()->json(['message' => 'Invalid Request', 'code' => 'error']); } }