Beispiel #1
0
 /**
  * Display a listing of the resource.
  * @return Response
  */
 public function index()
 {
     $tickets = Ticket::where('tickets.student_id', $this->student->id)->with('replies', 'replies.owner')->select('tickets.id', 'tickets.subject', 'tickets.open', 'tickets.updated_at', 'tr.seen')->leftJoin('ticket_replies as tr', function ($j) {
         $j->on('tr.ticket_id', '=', 'tickets.id')->where('tr.user_id', '>=', 1)->where('tr.seen', '=', 0);
     })->groupBy('tickets.id')->orderBy('tickets.updated_at', 'DESC')->get();
     return response()->json($tickets, 200, [], JSON_NUMERIC_CHECK);
 }
Beispiel #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'));
 }
Beispiel #3
0
 public function show(Ticket $tickets, Request $request)
 {
     $ticket = $tickets;
     $ticket->load('replies', 'replies.files', 'replies.student', 'replies.user', 'history');
     $seen = false;
     $ticket->replies->each(function ($reply) use(&$seen) {
         if ($reply->owner_type == 'students' && $reply->seen == 0) {
             $seen = true;
             $reply->seen = 1;
             $reply->save();
         }
     });
     if ($seen) {
         event(new UserSeenTicket($ticket->id, $ticket->student_id));
     }
     $tickets = Ticket::where('student_id', $ticket->student_id)->pluck('subject', 'id');
     if ($request->ajax()) {
         return response()->json(['total' => $ticket->replies->count(), 'view' => view('tickets::tickets._replies', compact('ticket'))->render()]);
     }
     $options = [];
     $departments = TicketDepartment::withDepth()->defaultOrder()->orderBy('parent_id', 'ASC')->get();
     foreach ($departments as $department) {
         $options[$department->id] = str_repeat("----", $department->depth) . $department->name;
     }
     return view('tickets::tickets.show', compact('ticket', 'tickets', 'options'));
 }