Пример #1
0
 public function actionBulk(Request $req, TicketDepartment $TicketDepartment)
 {
     if (!$req->has('table_records')) {
         return redirect()->route('tickets.departments.index');
     }
     $ids = $req->input('table_records');
     $input = $req->all();
     if ($input['submit'] == 'delete') {
         $TicketDepartment->destroy($ids);
     }
     return redirect()->route('tickets.departments.index')->with('success', trans('tickets::departments.delete_bulk_success'));
 }
Пример #2
0
 public function show(Ticket $Ticket, $id, Request $request)
 {
     $ticket = Ticket::where('student_id', student()->id)->with('replies', 'replies.student', 'replies.user')->findOrFail($id);
     $departments = TicketDepartment::withDepth()->get();
     $options = [NULL => NULL];
     foreach ($departments as $department) {
         $options[$department->id] = str_repeat("----", $department->depth) . $department->name;
     }
     foreach ($ticket->replies as $reply) {
         if (!empty($reply->user_id)) {
             $reply->seen = 1;
             $reply->save();
         }
     }
     if ($request->ajax()) {
         return response()->json(['total' => $ticket->replies->count(), 'view' => view('students::tickets._show_list', compact('ticket'))->render()]);
     }
     return view('students::tickets.show', compact('ticket', 'options'));
 }
Пример #3
0
 public function actionBulk(Request $request)
 {
     $input = $request->all();
     $action = $input['submit'];
     $ids = $input['table_records'];
     if ($action == 'update') {
         $data = [];
         if (!empty($input['ticket_category_id'])) {
             $data['ticket_category_id'] = $input['ticket_category_id'];
         }
         if (!empty($input['department_id'])) {
             $data['department_id'] = $input['department_id'];
         }
         if (!empty($input['open'])) {
             $data['open'] = 0;
         }
         if (!empty($input['priority'])) {
             $data['priority'] = $input['priority'];
         }
         if (!empty($data)) {
             foreach ($ids as $id) {
                 $descriptions = [];
                 $ticket = Ticket::with('department')->find($id);
                 if (isset($data['department_id']) and $data['department_id'] == $ticket->department_id) {
                     unset($data['department_id']);
                 }
                 if (isset($data['ticket_category_id']) and $data['ticket_category_id'] == $ticket->ticket_category_id) {
                     unset($data['ticket_category_id']);
                 }
                 if (isset($data['open']) and $data['open'] == $ticket->open) {
                     unset($data['open']);
                 }
                 if (isset($data['department_id']) && !empty($data['department_id'])) {
                     $descriptions[] = trans('tickets::tickets.histories.department_changed', ['user' => user()->name, 'old' => $ticket->department->name, 'new' => TicketDepartment::find($data['department_id'])->name]);
                 }
                 if (isset($data['open'])) {
                     $descriptions[] = trans('tickets::tickets.histories.ticket_closed', ['user' => user()->name]);
                 }
                 if (isset($data['priority']) && !empty($data['priority'])) {
                     $descriptions[] = trans('tickets::tickets.histories.priority_changed', ['user' => user()->name, 'old' => trans('tickets.tickets.priorities.' . $ticket->priority), 'new' => trans('tickets.tickets.priorities.' . $data['priority'])]);
                 }
                 if (!empty($data)) {
                     event(new TicketUpdated($ticket, $descriptions));
                     if (!$ticket->fill($data)->save()) {
                         return $ticket->errors();
                     }
                 }
             }
             return redirect()->back()->with('success', trans('tickets::tickets.bulk_update_success'));
         } else {
             return redirect()->back()->with('warning', trans('tickets::tickets.bulk_update_no_data'));
         }
     }
 }