我的大脑突然在这个问题上崩溃了.非常感谢任何愿意帮助我的人.
这是laravel 5.4中的LengthAwarepaginator
这是代码.
$collection = [];
foreach ($maincategories->merchantCategory as $merchantCat) {
foreach ($merchantCat->merchantSubcategory as $merchantSub) {
foreach($merchantSub->products as $products){
$collection[] = $products;
}
}
}
$paginate = new LengthAwarePaginator($collection, count($collection), 10, 1, ['path'=>url('api/products')]);
dd($paginate);
它显示得很完美,但问题是项目是100.这就是我所有的物品,我指定的是正确的.我只需要显示10个.
Base on LengthAwarePaginator constructor. Here is the reference.
public function __construct($items, $total, $perPage, $currentPage = null, array $options = [])
Here is the screen shot.
我哪里做错了?TY