0
我有这个疑问Laravel,如何选择数据,如果关系条件为真
$organisationUserNotifications = OrganisationUserNotification::
whereHas('user',function($user){
$user->where('status',STATUS_ACTIVE);
})
->orWhere('new_comment',ORGANISATION_NOTIFICATION_ACTIVE)
->orWhere('new_review',ORGANISATION_NOTIFICATION_ACTIVE)
->orWhere('new_salary',ORGANISATION_NOTIFICATION_ACTIVE)
->get();
这个查询得到结果谁拥有new_comment->1
或new_review->1
或new_salary->1
所有的用户,我有user
表
id
name
status
1
|us_1
|0
2
|us_2
|1
3
|us_3
|1
和notification
表
id
new_comment
new_review
new_salary
1
|0
|1
|1
2
|1
|0
|1
3
|1
|0
|1
此查询获取所有行,因为用户1具有status
0或请任何想法 如何验证等where
如果用户是活跃的,没有leftjoin