Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.
While developing one of my project in Laravel framework, I have shared a fine piece of code on community portal stackoverflow, which I wish share as below. Hope it will help devs
http://stackoverflow.com/questions//laravel-wherein-or-wherein/#
Almost2 years have passed, hope that you have already found a way to use wherein and orwherein in your application.
I am answering this because it may help others.
Assuming you know the eloquent queries :
If we have a model called User and we want to find list of users having id2,,
We can find it using following query
$users = User::whereIn('id', [2,,])->get();
Now if you want to find all the records having id2,, or1,,
Then you have to combined both whereIn and orWhereIn , there is a way to do this :
$users = User::whereIn('id', [2,,])->whereIn('id',[1,,],'or')->get();
You may be also interested in whereNotIn method which is desined to filters the collection by a given key / value not contained within the given array:
Hope this answer is useful.
Thank you