you can write raw statements
Suggestion: add a DB::whereNot equivalent to the DB::where closure syntax
I just encountered a situation where I needed to write a workaround for an import from a db that is having issues. The sql where clause that selected the offending rows had a dozen conditions, so the obvious way to instead exclude the those rows is to simply surround the whole clause with not({conditions}). I went to implement this in Laravel, and found that there is no whereNot(function ($q) {...} equivalent to where(function ($q) {...}
The solution was to completely change the clauses from
$query->whereNot(function ($q) {
$q->whereNull(...)
->whereNull(...)
->whereNull(...)
->whereNull(...);
});
which had resulted in an error of Invalid column name 'not'. to
$query->where(function ($q) {
$q->whereNotNull(...)
->orWhereNotNull(...)
->orWhereNotNull(...)
->orWhereNotNull(...);
});
This is somewhat inconvenient. There ought to be a way to replicate the where not({conditions}) functionality in my opinion.
Please or to participate in this conversation.