public function showTicketsAjaxHandler()
 {
     $userId = Session::get('ig_supplier')['id'];
     $objUserTicket = Ticket::getInstance();
     $where = array('rawQuery' => 'user_id=?', 'bindParams' => [$userId]);
     $selectedColumns = array('users.*', 'tickets.*');
     $ticketDetailsOfUser = $objUserTicket->getUserInfoByUserId($where, $selectedColumns);
     //        dd($ticketDetailsOfUser);
     $tickets = new Collection();
     $ticketDetailsOfUser = json_decode(json_encode($ticketDetailsOfUser), true);
     foreach ($ticketDetailsOfUser as $tdu) {
         $id = $tdu['ticket_id'];
         if ($tdu['ticket_status'] == 0) {
             $status = 'opened';
         } else {
             $status = 'closed';
         }
         $tickets->push(['ticket_id' => $tdu['ticket_id'], 'name' => $tdu['name'] . $tdu['lastname'], 'email' => $tdu['email'], 'subject' => $tdu['subject'], 'descriptions' => $tdu['descriptions'], 'status' => $status, 'created_at' => $tdu['created_at']]);
     }
     return Datatables::of($tickets)->make(true);
 }
 /**
  * This is for joining users table and tickets table so that i can get the users info in ticket details page
  * @since 11-2-2016
  * @author Saurabh Kumar <*****@*****.**>
  */
 public function getAvaiableUsersDetails()
 {
     try {
         $result = Ticket::join('users', function ($join) {
             $join->on('tickets.user_id', '=', 'users.id');
         })->select()->get();
         return $result;
     } catch (QueryException $e) {
         echo $e;
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  string  $slug
  * @return \Illuminate\Http\Response
  */
 public function destroy($slug)
 {
     $ticket = Ticket::whereSlug($slug)->firstOrFail();
     $ticket->delete();
     return redirect('/ticket')->with('status', 'The ticket ' . $slug . ' has been deleted!');
 }