Laravel scout whereNotNull is not working
Posted on:January 30, 2023 at 10:00 AM
Hello.
If you want to use whereNull()
or whereNotNull()
in the Laravel Scout, you may get this error Method Laravel\Scout\Builder::whereNotNull does not exist
. It’s because scout officially does not support whereNull()
or whereNotNull()
.
Then how to achieve this?
There is a hack you can follow to achieve it. You can use query()
and pass a closure in it.
For example:
User::search('Taylor')->query(function ($query) {
$query->where('email_verified_at', '!=', 'NULL');
})->get();
This should work.
If you are interested more, learn more in the official repo