0

Laravel 查询构建器需要从多个连接表中分页。

我已经尝试了很多方法来分页这个查询。但什么都没有。

控制器.php

$ord_heds = DB::select('select d.family, d.category, d.product_img, d.ord_ref, m.min_qty, m.max_qty, t.qty, t.value, SUM(replace(d.value,",","")) as ordval, SUM(replace(d.qty,",","")) as Tord_qty, COUNT(d.qty) as no_of_items_ordered, (select COUNT(itemCode) as mcount from item_statuses where '.'s'.$siteG.' ="'.$site.'" and itemCode in (select itemCode FROM items WHERE category=d.category and brand=d.family)) as manCount, (select COUNT(itemCode) as mcount1 from item_statuses where '.'s'.$siteG.' ="'.$site.'" and itemCode in (select itemCode FROM items WHERE category=d.category and brand=d.family and itemCode in (select itemcode FROM ord_dets where ord_dets.site = "'.$ordSite.'"))) as ordManCount FROM ord_dets d JOIN ord__heds h ON d.ord_ref = h.id INNER JOIN min__maxes m ON d.category = m.category AND d.site = m.site AND d.scode = m.season INNER JOIN targets t ON d.category = t.category AND d.family = t.brand AND d.month = t.month AND d.year = t.year AND d.site = t.site WHERE h.month = "'.$date[1].'" AND h.year = "'.$date[0].'" AND h.site = "'.$ordSite.'" GROUP BY d.family, d.category, d.product_img, d.ord_ref, m.min_qty, m.max_qty, t.qty, t.value');

$pag = $ord_heds->paginate(10);

dd($pag);

上面的代码导致错误“FatalThrowableError Call to a member function paginate() on array”。

4

0 回答 0