From a2b8679a75490c62af1d17463c64dda06a6eb90a Mon Sep 17 00:00:00 2001 From: pavelhouzva Date: Thu, 16 Apr 2020 08:13:06 +0200 Subject: [PATCH] added pagination to collection --- src/Pinterest/Models/Collection.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Pinterest/Models/Collection.php b/src/Pinterest/Models/Collection.php index 97f768e..dc45e8b 100644 --- a/src/Pinterest/Models/Collection.php +++ b/src/Pinterest/Models/Collection.php @@ -134,6 +134,14 @@ public function hasNextPage() return ($this->response != null && isset($this->response->page['next'])); } + public function nextPage() + { + if ($this->hasNextPage()) { + $response = $this->master->request->execute('GET', $this->response->page['next']); + return new self($this->master, $response, $this->model); + } + } + /** * Return the item at the given index * @@ -255,4 +263,4 @@ public function getIterator() { return new \ArrayIterator($this->items); } -} \ No newline at end of file +}