diff --git a/app/Classes/Pterodactyl.php b/app/Classes/Pterodactyl.php
index eeb0e3a6..7df0229e 100644
--- a/app/Classes/Pterodactyl.php
+++ b/app/Classes/Pterodactyl.php
@@ -33,6 +33,14 @@ class Pterodactyl
])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
}
+ public static function clientadmin()
+ {
+ return Http::withHeaders([
+ 'Authorization' => 'Bearer ' . config("SETTINGS::SYSTEM:PTERODACTYL:ADMIN_USER_TOKEN"),
+ 'Content-type' => 'application/json',
+ 'Accept' => 'Application/vnd.pterodactyl.v1+json',
+ ])->baseUrl(config("SETTINGS::SYSTEM:PTERODACTYL:URL") . '/api');
+ }
/**
* @return Exception
*/
@@ -317,4 +325,11 @@ class Pterodactyl
]
]);
}
+
+ public static function powerAction(Server $server, $action)
+ {
+ return self::clientadmin()->post("/client/servers/{$server->identifier}/power", [
+ "signal" => $action
+ ]);
+ }
}
diff --git a/app/Http/Controllers/ServerController.php b/app/Http/Controllers/ServerController.php
index b77fb955..ed965b1e 100644
--- a/app/Http/Controllers/ServerController.php
+++ b/app/Http/Controllers/ServerController.php
@@ -289,6 +289,9 @@ class ServerController extends Controller
if ($response->failed()) return $this->serverCreationFailed($response, $server);
//update user balance
$user->decrement('credits', $priceupgrade);
+ //restart the server
+ $response = Pterodactyl::powerAction($server, "restart");
+ if ($response->failed()) return $this->serverCreationFailed($response, $server);
return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
}
else
diff --git a/resources/views/servers/settings.blade.php b/resources/views/servers/settings.blade.php
index 91b3997d..011e7014 100644
--- a/resources/views/servers/settings.blade.php
+++ b/resources/views/servers/settings.blade.php
@@ -254,6 +254,7 @@
@endforeach
{{__("Once the Upgrade button is pressed, we will automatically deduct the amount for the first hour according to the new product from your credits")}}.
+
{{_("Server will be automatically restarted once upgraded")}}