From 6a431edd8be08087e079c97cd6df8f2811b3e310 Mon Sep 17 00:00:00 2001 From: AVMG20 Date: Mon, 5 Jul 2021 20:47:29 +0200 Subject: [PATCH] Allocation limit added --- app/Classes/Pterodactyl.php | 4 +++- app/Http/Controllers/HomeController.php | 2 -- database/seeders/Seeds/ConfigurationSeeder.php | 11 +++++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/Classes/Pterodactyl.php b/app/Classes/Pterodactyl.php index 60994f4c..a48b569f 100644 --- a/app/Classes/Pterodactyl.php +++ b/app/Classes/Pterodactyl.php @@ -2,6 +2,7 @@ namespace App\Classes; +use App\Models\Configuration; use App\Models\Egg; use App\Models\Nest; use App\Models\Node; @@ -124,7 +125,8 @@ class Pterodactyl */ public static function getAllocations(Node $node) { - $response = self::client()->get("/application/nodes/{$node->id}/allocations"); + $per_page = Configuration::getValueByKey('ALLOCATION_LIMIT' , 200); + $response = self::client()->get("/application/nodes/{$node->id}/allocations?per_page={$per_page}"); if ($response->failed()) throw self::getException(); return $response->json(); } diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index c09a2c37..202a19c1 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -2,8 +2,6 @@ namespace App\Http\Controllers; -use App\Models\UsefulLink; -use Illuminate\Contracts\Support\Renderable; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; diff --git a/database/seeders/Seeds/ConfigurationSeeder.php b/database/seeders/Seeds/ConfigurationSeeder.php index a6f7151b..7dc5e46b 100644 --- a/database/seeders/Seeds/ConfigurationSeeder.php +++ b/database/seeders/Seeds/ConfigurationSeeder.php @@ -109,5 +109,16 @@ class ConfigurationSeeder extends Seeder 'type' => 'boolean', 'description' => 'Prevent users from making multiple accounts using the same IP address' ]); + + //per_page on allocations request + Configuration::firstOrCreate([ + 'key' => 'ALLOCATION_LIMIT', + ], [ + 'value' => '200', + 'type' => 'integer', + 'description' => 'The maximum amount of allocations to pull per node for automatic deployment, if more allocations are being used than this limit is set to, no new servers can be created!' + ]); + + } }