没有条件 if 语句和 else 语句

Not getting condiotions if statement and else statement

$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();

以上代码是我的查询。我要根据登录用户出示票

在您的 Laravel 查询中使用 where('groups_users.users_id', Auth::id()) 根据登录用户获取门票:

$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();