i have this query
$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();
this query get result for all users who have new_comment->1
or new_review->1
or new_salary->1
i have user
table
id
name
status
1
|us_1
|0
2
|us_2
|1
3
|us_3
|1
and notification
table
id
new_comment
new_review
new_salary
1
|0
|1
|1
2
|1
|0
|1
3
|1
|0
|1
this query get all rows because user 1 have status
0 or new_review
1 please any idea how to verify other where
if user is active , without leftjoin
ok , i found the solution if anyone needs it
$organisationUserNotifications = OrganisationUserNotification::
whereHas('user',function($user){
$user->where('status',STATUS_ACTIVE);
})
->where(function($query){
$query->orWhere('new_comment',ORGANISATION_NOTIFICATION_ACTIVE);
$query->orWhere('new_review',ORGANISATION_NOTIFICATION_ACTIVE);
$query->orWhere('new_salary',ORGANISATION_NOTIFICATION_ACTIVE);
})
->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.