Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Laravel查询生成器仅获取具有特定进度的项_Php_Mysql_Laravel_Eloquent_Laravel Query Builder - Fatal编程技术网

Php Laravel查询生成器仅获取具有特定进度的项

Php Laravel查询生成器仅获取具有特定进度的项,php,mysql,laravel,eloquent,laravel-query-builder,Php,Mysql,Laravel,Eloquent,Laravel Query Builder,您好,我正在尝试获取具有特定产品进度的产品订单。 我的Laravel查询如下所示: return Order::whereHas('products.progress', function (Builder $query) { $query->where('progress_id', 100) ->orWhereBetween('progress_id', [160, 240]); }) ->with('products.progr

您好,我正在尝试获取具有特定产品进度的产品订单。

我的Laravel查询如下所示:

return Order::whereHas('products.progress', function (Builder $query) {
    $query->where('progress_id', 100)
        ->orWhereBetween('progress_id', [160, 240]);
      })
    ->with('products.progress')
    ->select('orders.id', 'orders.customer_id', 'orders.created_at')
    ->get();
在查询中,我设置了一个where和where-between,最后一个产品的进度id为50,不应将其加载到订单中

怎么做?谢谢你的阅读。

我想你是想看的

所以你的(哪里)应该在装货

return Order::with(['products'=>function($query){
        $query->whereHas('progress',function ($query){
            $query->where('progress_id', 100)
                ->orWhereBetween('progress_id', [160, 240]);
        })->with('progress');
    }])
        ->select('orders.id', 'orders.customer_id', 'orders.created_at')
        ->get();

您好,OMR,感谢您的回复,我尝试了您的解决方案,但它只显示进度关系。产品本身仍在订购中。非常感谢OMR您的解决方案是正确的,非常有帮助。