How to create "NOT" wrapped criteria, ie:
WHERE
id=1 AND NOT (tag='foo' OR tag='bar')
I know I can wrap with closure
$q->where('id', 1)
->where(function ($iq) {
$iq->where('tag', 'foo')
->orWhere('tag', 'bar');
});
Something like this (which does not work):
$q->where('id', 1)
->where('!=', function ($iq) {
$iq->where('tag', 'foo')
->orWhere('tag', 'bar');
});
Edit:
I have Laravel7
2
Answers
Laravel 10 has where not clause but Laravel 7 does not.
But this works:
The specific example you have provided is better done as: