Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using orWhere() in collection

Tags:

laravel

I've been looking for the same functionality of eloquent orWhere() but in collection. I just found that I can chain multiple where() but I haven't found something like orWhere().

So basically the question is, is there a way to achieve something like orWhere() in collections?

like image 876
Luis felipe De jesus Munoz Avatar asked Dec 10 '22 07:12

Luis felipe De jesus Munoz


1 Answers

You have 2 solutions for this:

  • Use ->filter & add your own conditions
  • Make it in 2 steps using the ->where() then use ->merge to make the final collection
like image 142
ahmad Avatar answered Feb 12 '23 16:02

ahmad