如何在Laravel 5.6中使用chunk()从数据库中根据产品获取类别

时间:2018-07-18 04:10:55

标签: php laravel laravel-5 laravel-5.6

有人可以帮助我解决这个问题吗?我尝试使用块方法根据类别获取数据,而且我使用集合。但是,当我在集合中使用Where子句时,它将给我空值。请帮助我。

$products=DB::table('stock_management')
->join('warehouse_products','stock_management.product_id','=','warehouse_products.id')
->leftjoin('brand','warehouse_products.brand_id','=','brand.id')
->select('warehouse_products.*','brand.name as Brandname','brand.remember_token as color')
->orderBy('brand.name','ASC')
->get()
->chunk(50);

$collection=collect($products);
$getProduct=$collection->where('categories_id','=',34);
$catProduct=$getProduct->all();
dd($catProduct);

0 个答案:

没有答案