Merge pull request #525 from SahrulGnwn/development
Restart After Upgrade
This commit is contained in:
commit
6331ea0b66
3 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -254,6 +254,7 @@
|
|||
@endforeach
|
||||
</select>
|
||||
<br> {{__("Once the Upgrade button is pressed, we will automatically deduct the amount for the first hour according to the new product from your credits")}}. <br>
|
||||
<br> {{_("Server will be automatically restarted once upgraded")}}
|
||||
</div>
|
||||
<div class="modal-footer card-body">
|
||||
<button type="submit" class="btn btn-primary" style="width: 100%"><strong>{{__("Change Product")}}</strong></button>
|
||||
|
|
Loading…
Reference in a new issue