Skip to content
Advertisement

Laravel Eloquent – Query with multiples parameters

I’m new to the Laravel framework and I could need a little help from you.

Could someone help me to convert this request into Eloquent ?

JavaScript

For the moment I have managed to find a solution but I am running as many queries as the number of parameters.

JavaScript

So it comes down to doing :

JavaScript

So I don’t think it’s very efficient knowing that potentially I would have many more parameters.

Thanks

Advertisement

Answer

You can use the whereIn method:

JavaScript

This should give you a query like this:

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