“$dbOrderStatusArray”返回包含数据的数组
$dbOrderStatusArray = SitesOrderStatus::where("internal_status_id", 2)->select("site_id", "order_status_id")->get()->toArray();
接收数据的示例如下。
$dbOrderStatusArray = [
["site_id" => 7230,"order_status_id" => 17],
["site_id" => 7230,"order_status_id" => 23],
["site_id" => 7230,"order_status_id" => 25],
["site_id" => 3881,"order_status_id" => 2],
["site_id" => 3881,"order_status_id" => 19],
["site_id" => 3881,"order_status_id" => 17]
];
我试图通过获取数据和收集数据来得到一个按顺序排列的列表。然后我想添加排序和分页。但是无论我多么努力,我还是得到了一个错误。
Method Illuminate\Support\Collection::paginate does not exist.
or
Method Illuminate\Support\Collection::links does not exist..
$orders = collect([]);
foreach ($dbOrderStatusArray as $item) {
$orders = $orders->concat(SitesOrders::where('site_id', $item['site_id'])->where('order_status_id', $item['order_status_id'])->get());
}
$paginate = $orders->sortByDesc('date_added')->paginate($data['paginate']);
$data['orders'] = $paginate;
也许有人遇到了这个问题,可以提供帮助?在开始时,我得到所有商店的订单状态,有id 2的内部网站状态。
1条答案
按热度按时间py49o6xq1#
在您的laravel版本中,不能在集合示例上运行
paginate()
。它应该在QueryBuilder示例上使用。