Reputation: 782
$products = $this->productRepository->paginate(1);
I want to get only one item at a time but the paginate() function related to pagination are not working. My laravel version is 5.7.6. when i use dd($products) it returns:
Collection {#468
#items: array:2 [
0 => Product {#469}
1 => Product {#470}
]
}
Upvotes: 0
Views: 135
Reputation: 557
You are accessing the collection directly which does not paginate.
Try $products = $this->productRepository()->paginate(1);
using productRepository()
gives you the query builder instead, which you can then paginate
Upvotes: 1