Skip to content
Advertisement

query laravel not working if pass variable in Where NOT IN

I’m trying to filter items from a database table what I do is get the ids that I want to exclude and then through -> whereNotIn in laravel, I pass the ids

JavaScript

up to this point I have no problem. the result of “implode” gives me the ids I want to remove

this is the result of $idbike and $notid:

enter image description here

this is the query I write to exclude the ids found:

JavaScript

the problem is that it doesn’t exclude me the ids passed with $notid

but if I manually pass the ids, it removes them instead:

JavaScript

am I doing something wrong?

Advertisement

Answer

You shouldn’t implode $notid, that makes it a string and Laravels whereNotIn() already does that for you.

JavaScript

And remove the $notid parameter, as it is not needed.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement