Reputation: 99
How to perform queries in the Eloquent Laravel 6 database using "or" in columns of the same table?
Example: I want to search for the word "coffee" in the "products" table in name, description and ean1 columns. how do I do this using Eloquent?
Upvotes: 0
Views: 29
Reputation: 350
You can do something like this:
$search_str = 'coffee'
$filter = Product::where('name', 'LIKE', '%' . $search_str . '%')->orWhere('description', 'LIKE', '%' . $search_str . '%')
Upvotes: 1