我在表名中有两列分别是产品正常价格和产品销售价格。我必须根据用户给定的价格范围搜索最小价格产品。从单个列中搜索最低价格很容易,但是从两个列中搜索最低价格似乎都很困难。
$products = $products->whereBetween(['ecommerce_sku.regular_price','ecommerce_sku.sale_price'], [$minPrice, $maxPrice]);
您可以将常规价格和销售价格分开。
$products = $products
->whereBetween('ecommerce_sku.sale_price', [$minPrice, $maxPrice])
->whereBetween('ecommerce_sku.regular_price', [$minPrice, $maxPrice]);