我脑子突然卡住了。非常感谢任何想要帮助我的人。
这是 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个。
根据 LengthAwarePaginator 构造函数。这是参考资料。
public function __construct($items, $total, $perPage, $currentPage = null, array $options = [])
这是截图。
我错在哪里了?谢谢。
forPage()
方法)。 - patricus