如何在 laravel 6 中使用 (or) in laravel 6 进行相同 table 但在不同列中的查询?

How to use (or) in laravel 6 for a query in the same table but in different columns?

如何在 Eloquent Laravel 6 数据库中使用相同 table 的列中的 "or" 执行查询?

示例:我想在名称、描述和 ean1 列的 "products" table 中搜索词 "coffee"。 如何使用 Eloquent?

执行此操作

你可以这样做:

$search_str = 'coffee'

$filter = Product::where('name', 'LIKE', '%' . $search_str . '%')->orWhere('description', 'LIKE', '%' . $search_str . '%')