lifesound's avatar

I do not know why orWhereNull does not working as expected

Laravel version 9

If the scanned column is false or null, I want to select the product.

i used $products->where('scanned',false)->orWhereNull('scanned')

not yield the right result as I checked by MySQL itself

is it deprecated?

i have this err Method Illuminate\Database\Eloquent\Collection::orWhereNull does not exist.

0 likes
3 replies
JussiMannisto's avatar
Level 50

It's a method of the query builder, not the collection class. You can use it in your query, e.g.

$products = Product::where('scanned', false)->orWhereNull('scanned')->get();

But you can't use it on the $products collection afterwards.

Please or to participate in this conversation.