3 回答
TA贡献1155条经验 获得超0个赞
尝试这个:
Order::whereHas('products' => function ($query) {
$query->whereHas('progress', function ($query) {
$query->where('progress_id', 30)->orWhereBetween('progress_id', [60, 90]);
});
$query->whereHas('product', function ($query) {
$query->where('vendor_id', 3);
});
// $query->select('id', 'order_id', 'product_id', 'quantity'); // This line will cause error
}])->with(['products', 'products.product:id,identifier,reference,shipping_id,vendor_id'])
->where('status_id', 15)
->get();
TA贡献1825条经验 获得超6个赞
尝试这个
Order::whereHas('products')->with(['products' => function ($query) {
$query->whereHas('progress', function ($query) {
$query->where('progress_id', 30)->orWhereBetween('progress_id', [60, 90]);
});
$query->whereHas('product', function ($query) {
$query->where('vendor_id', 3);
})->with(['product' => function ($query) {
$query->select('id', 'identifier', 'reference', 'shipping_id');
}]);
$query->select('id', 'order_id', 'product_id', 'quantity');
}])->where('status_id', '=', 15)
->select('orders.id', 'orders.customer_id', 'orders.created_at')
->get();
- 3 回答
- 0 关注
- 89 浏览
添加回答
举报