Esempio n. 1
0
 public function techsupport_report()
 {
     // 	$user_tickets = TicketReply::with('users')->get();
     $user_tickets = TicketReply::groupBy('user_id')->selectRaw('count(ticket_replies.id) as rep_count , users.name as username')->join('users', function ($join) {
         $join->on('users.id', '=', 'ticket_replies.user_id');
     })->get();
     return view('tickets::reports.techsupport', compact('user_tickets'));
 }
Esempio n. 2
0
 public function reply(Request $request, Ticket $ticket)
 {
     $input = $request->all();
     if ($input['submit'] == 'reply') {
         $data = ['user_id' => user()->id, 'body' => $request->input('body'), 'owner_type' => 'users', 'owner_id' => user()->id, 'ticket_id' => $ticket->id];
         $reply = TicketReply::create($data);
         if (!empty($input['files'])) {
             $files = TicketReplyFile::where('id', $input['files'])->get();
             $reply->files()->saveMany($files);
         }
         if ($ticket->open == 0) {
             $ticket->open = 1;
             $ticket->save();
         }
         // temp for order
         // dd($ticket->student_id);
         // $student = Student::with('department')->find($ticket->student_id);
         //$ticket->department_id = 11 + $student->department->term->year->id;
         $ticket->priority = 'low';
         $ticket->save();
         //end
         $ticket->replies()->save($reply);
         event(new UserRepliedToTicket($reply, $ticket->student_id));
         event(new UserSeenTicket($ticket->id, $ticket->student_id));
         if ($request->ajax()) {
             $ticket->load('replies', 'replies.owner', 'replies.files', 'replies.student', 'replies.user');
             foreach ($ticket->replies as $reply) {
                 if (!empty($reply->student_id)) {
                     $reply->seen = 1;
                     $reply->save();
                 }
             }
             return response()->json(['view' => view('tickets::tickets._replies', compact('ticket'))->render()]);
         }
         $message = trans('tickets::tickets.create_reply_success');
     } elseif ($input['submit'] == 'close') {
         $ticket->open = 0;
         $ticket->save();
         $message = trans('tickets::tickets.ticket_closed_success');
         return redirect()->route('tickets.tickets.index')->with('success', $message);
     } elseif ($input['submit'] == 'transferButton') {
         if (!empty($input['department_id'])) {
             $data['department_id'] = $input['department_id'];
             $data['comment'] = $input['comment'];
         }
         if (isset($data['ticket_category_id']) and $data['ticket_category_id'] == $ticket->ticket_category_id) {
             unset($data['ticket_category_id']);
         }
         if (isset($data['department_id']) && !empty($data['department_id'])) {
             //inser in ticket_comments
             $descriptions[] = trans('tickets::tickets.histories.department_changed', ['user' => user()->name, 'old' => $ticket->department->name, 'new' => TicketDepartment::find($data['department_id'])->name, 'comment' => $data['comment']]);
         }
         if (!empty($data)) {
             event(new TicketUpdated($ticket, $descriptions));
             if (!$ticket->fill($data)->save()) {
                 return $ticket->errors();
             }
         }
         $message = trans('tickets::tickets.bulk_update_success');
         return redirect()->route('tickets.tickets.index')->with('success', $message);
     }
     return redirect()->back()->with('success', $message);
 }
Esempio n. 3
0
 /**
  * seen the specified resource in storage.
  * @param  Request $request
  * @return Response
  */
 public function seen(Request $request)
 {
     TicketReply::where('ticket_id', $request->input('ticket_id'))->where('owner_type', 'users')->update(['seen' => 1]);
     return response()->json(true, 200, [], JSON_NUMERIC_CHECK);
 }