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')); } }
public function store(Request $request) { if (!Helper::getMode()) { return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE')); } $config = Helper::getConfiguration(); $config_type = $request->input('config_type'); $input = $request->all(); foreach ($input as $key => $value) { if ($key != '_token' && $key != 'config_type') { $config[$key] = $value; } } if ($request->input('next_ticket_no')) { $max_ticket_no = \App\Ticket::max('ticket_no'); if (isset($max_ticket_no) && $request->input('next_ticket_no') < $max_ticket_no) { return redirect()->back()->withErrors('Next ticket number cannot be less than existing ticket number.'); } } $filename = base_path() . config('paths.CONFIG_PATH'); File::put($filename, var_export($config, true)); File::prepend($filename, '<?php return '); File::append($filename, ';'); return redirect('/configuration#' . $config_type)->withSuccess(config('constants.SAVED')); }