/** * Actual process of storing Ticket * * @param TicketRequest $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function store(TicketRequest $request) { $input = $request->all(); Ticket::create($input); return redirect('/tickets')->with(['flash_message' => 'You have successfully updated the ticket', 'flash_message_important' => true]); }
/** * Actual process of storing Ticket * * @param TicketRequest $request * @return Redirector */ public function store(TicketRequest $request) { $input = $request->all(); $this->ticket->create($input); return redirect('/user/profile')->with(['flash_message' => 'You have successfully created a ticket', 'flash_message_important' => true]); }
/** * Update the specified resource in storage. * * @param int $id * @param TicketRequest $request * @return Response */ public function update($id, TicketRequest $request) { $ticket = Ticket::findOrFail($id); $ticket->update($request->all()); // update users in pivot table $this->syncUsers($ticket, $request['user_list']); return redirect("tickets/{$id}"); }
public function store(TicketRequest $request, Ticket $ticket) { if (!Entrust::can('create_ticket')) { return redirect('/dashboard')->withErrors(config('constants.NA')); } $data = $request->all(); $ticket->fill($data); $ticket->ticket_status = 'open'; $ticket->user_id = Auth::user()->id; $service_time = Helper::getServiceTime($ticket->ticket_priority); if ($service_time['resolution_time_type'] == 'business_hour') { $ticket->resolution_due_time = Helper::calculateDueTime($service_time['resolution_time'], date('Y-m-d H:i')); } else { $ticket->resolution_due_time = date('Y-m-d H:i', $service_time['resolution_time'] * 60 + strtotime(date('Y-m-d H:i'))); } if ($service_time['response_time_type'] == 'business_hour') { $ticket->response_due_time = Helper::calculateDueTime($service_time['response_time'], date('Y-m-d H:i')); } else { $ticket->response_due_time = date('Y-m-d H:i', $service_time['response_time'] * 60 + strtotime(date('Y-m-d H:i'))); } $max_ticket_no = Ticket::max('ticket_no'); $next_ticket_no = config('config.next_ticket_no'); if ($max_ticket_no >= $next_ticket_no) { $ticket->ticket_no = ++$max_ticket_no; } else { $ticket->ticket_no = $next_ticket_no; } $ticket->save(); Helper::storeCustomField($this->form, $ticket->id, $data); $activity = 'New Ticket added'; Activity::log($activity); $path = base_path() . '/config/template/' . config('config.domain') . '/new_ticket'; $content = ''; if (File::exists($path)) { $content = File::get($path); } $content = Helper::templateContent($content, 'ticket', $ticket); if ($content != '' && config('config.new_ticket_send_mail')) { $title = Helper::templateContent(config('template.new_ticket.title'), 'ticket', $ticket); Mail::send('template.mail', compact('content'), function ($message) use($ticket, $title) { $message->to($ticket->User->email)->subject($title); }); } if (Entrust::hasRole('user')) { return redirect('/view-ticket/' . $ticket->id)->withSuccess(config('constants.ADDED')); } else { return redirect('/ticket/' . $ticket->id)->withSuccess(config('constants.ADDED')); } }