Purpose of this new function is to provide a starting point for paginating Droplet requests.
This PR implements a new function for returning the total amount of Droplets. This is an initial enhancement based on #29 . Implementation is basic and is as follows:
Make API request for /droplets with $perPage = 1 and $page = 1 (we only need 1 result to get the meta object)
Get meta->total for Droplet Total
Return $total
Can be used like
// Total Droplets from API
$total = DigitalOcean::droplet()->getTotal();
// How many times we should iterate $page
$pages = ceil($total / $perPage);
for ($i = 1; $i <= $pages; $i++) {
$request = DigitalOcean::droplet()->getAll($perPage, $i);
foreach ($request as $item) {
array_push($droplets, $item);
}
}
Purpose of this new function is to provide a starting point for paginating Droplet requests.
This PR implements a new function for returning the total amount of Droplets. This is an initial enhancement based on #29 . Implementation is basic and is as follows:
/droplets
with$perPage = 1
and$page = 1
(we only need 1 result to get themeta
object)meta->total
for Droplet Total$total
Can be used like