Home > Blockchain >  Not getting condiotions if statement and else statement
Not getting condiotions if statement and else statement

Time:10-12

$tickets  = Ticket::select("tickets.cust_id","tickets.ticket_id","tickets.category_id","tickets.subject","tickets.priority","tickets.message","tickets.status","tickets.createdticket","tickets.last_reply","tickets.closing_ticket","tickets.auto_close_ticket","tickets.created_at","tickets.updated_at","groups_categories.group_id","groups_users.users_id")
   ->leftJoin('groups_categories','groups_categories.category_id','tickets.category_id')
   ->leftJoin('groups_users','groups_users.groups_id','groups_categories.group_id')
   ->get();

Above code is my query. I want the show the ticket according the login users

CodePudding user response:

Use where('groups_users.users_id', Auth::id()) in your Laravel query for get tickets based on Logged-in user:

$tickets  = Ticket::leftJoin('groups_categories','groups_categories.id','tickets.category_id')
       ->leftJoin('groups_users','groups_users.id','groups_categories.group_id')
       ->select("tickets.cust_id","tickets.ticket_id","tickets.category_id","tickets.subject","tickets.priority","tickets.message","tickets.status","tickets.createdticket","tickets.last_reply","tickets.closing_ticket","tickets.auto_close_ticket","tickets.created_at","tickets.updated_at","groups_categories.group_id","groups_users.users_id")
       ->where('groups_users.users_id', Auth::id())
       ->get();
  • Related