我收到订单清单时遇到问题。这不在Laravel中的WHERE IN
子句中。我该如何解决这个问题?
我使用array_chank
拆分某些部分的数组,并将每个部分与不同的WHERE IN
一起使用。
这是我的代码:
$data = [];
$total_price_orders = 0;
$prod_controller = new ProductController();
$promocode_controller = new CouponController();
$orderQuery = Order::query();
$products = new OrderProductController();
if ($request->has('vydavnytstvo')) {
$publishHousesVal = $request['vydavnytstvo'];
$publishHousesName = [];
foreach ($publishHousesVal as $item){
$house = DB::table('properties')->where('id', $item)->pluck('value')->toArray();
$publishHousesName[] = $house;
}
$productsArray = DB::table('products')->whereIn('publishing_house', $publishHousesName)->pluck('id')->toArray();
$orders = DB::table('order_product')->whereIn('product_id', $productsArray)->pluck('order_id')->toArray();
// $orderQuery->whereIn('id', $orders);
foreach (array_chunk($orders, 1000) as $array){
$orderQuery->whereIn('id', $array);
}