Beispiel #1
0
 public function update(TicketRequest $request, Ticket $ticket)
 {
     if (!Entrust::can('edit_ticket')) {
         return redirect('/dashboard')->withErrors(config('constants.NA'));
     }
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $data = $request->except('user_id');
     $ticket->fill($data)->save();
     $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'], $ticket->created_at);
     } else {
         $ticket->resolution_due_time = date('Y-m-d H:i', $service_time['resolution_time'] * 60 + strtotime($ticket->created_at));
     }
     if ($service_time['response_time_type'] == 'business_hour') {
         $ticket->response_due_time = Helper::calculateDueTime($service_time['response_time'], $ticket->created_at);
     } else {
         $ticket->response_due_time = date('Y-m-d H:i', $service_time['response_time'] * 60 + strtotime($ticket->created_at));
     }
     $ticket->save();
     Helper::updateCustomField($this->form, $ticket->id, $data);
     $ticket->assignedUser()->sync($request->input('user_id') ?: []);
     return redirect()->back()->withSuccess(config('constants.ADDED'));
 }