没有得到条件 if 语句和 else 语句
Posted
技术标签:
【中文标题】没有得到条件 if 语句和 else 语句【英文标题】:Not getting condiotions if statement and else statement 【发布时间】:2021-11-30 02:41:53 【问题描述】:$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-4
或 laravel-5
,是哪个?您的代码中的 if
和 else
语句在哪里?
【参考方案1】:
在您的 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();
【讨论】:
以上是关于没有得到条件 if 语句和 else 语句的主要内容,如果未能解决你的问题,请参考以下文章
Python基础语法—— 条件语句(if)+循环语句(for+while)