From 137f54818d2d8b242fc564b9502ef2de48cf9771 Mon Sep 17 00:00:00 2001 From: AVMG20 Date: Tue, 15 Jun 2021 17:39:43 +0200 Subject: [PATCH] Isseu: Pterodactyl zero allocations found #24 --- app/Classes/Pterodactyl.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Classes/Pterodactyl.php b/app/Classes/Pterodactyl.php index 30d95681..a0b5c99a 100644 --- a/app/Classes/Pterodactyl.php +++ b/app/Classes/Pterodactyl.php @@ -49,8 +49,12 @@ class Pterodactyl $response = self::getAllocations($node); $freeAllocations = []; - foreach ($response['data'] as $allocation) { - if (!$allocation['attributes']['assigned']) array_push($freeAllocations, $allocation); + if(isset($response['data'])){ + if (!empty($response['data'])) { + foreach ($response['data'] as $allocation) { + if (!$allocation['attributes']['assigned']) array_push($freeAllocations, $allocation); + } + } } return $freeAllocations;