Users::where('application_ID', '=', $request->application_ID)
->where(function ($query) {
$query->where('app_status','!=','')
->orWhere('app_status','!=','Accept')
->orWhere('app_status','!=','Reject')
->orWhere('app_status','!=','Comm Accept')
->orWhere('app_status','!=','Comm Reject');
})->get();
Output:
select * from `user` where `application_ID` = '0320120332330' and (`app_status` != 'Accept' or `app_status` != 'Reject' or `app_status` != 'Comm Accept' or `app_status` != 'Comm Reject')
In the above query if in my table I have app_status = Accept, Reject, Comm Accept and Comm Reject then the query return all record related to application_ID = '0320120332330' but I have already mention that if app_status != Accept, Reject, Comm Accept and Comm Reject then again it return all record. I don't know why?
!=, so you get every record. if it is "Accept" it is not "Reject" so the record is in your results... Basically 4 of the orWhere statements are always true