Fix Server upgrade || fix server overview total credits

This commit is contained in:
Dennis 2023-05-16 22:05:51 +02:00 committed by GitHub
commit b330e5a617
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 10 deletions

View file

@ -38,7 +38,7 @@ class OverViewController extends Controller
$counters = collect();
//Set basic variables in the collection
$counters->put('users', User::query()->count());
$counters->put('credits', number_format(User::query()->where('role', '!=', 'admin')->sum('credits'), 2, '.', ''));
$counters->put('credits', number_format(User::query()->whereHas("roles", function($q){ $q->where("id", "!=", "1"); })->sum('credits'), 2, '.', ''));
$counters->put('payments', Payment::query()->count());
$counters->put('eggs', Egg::query()->count());
$counters->put('nests', Nest::query()->count());

View file

@ -389,6 +389,10 @@ class ServerController extends Controller
$server->allocation = $serverAttributes['allocation'];
$response = $this->pterodactyl->updateServer($server, $newProduct);
if ($response->failed()) return redirect()->route('servers.index')->with('error', __("The system was unable to update your server product. Please try again later or contact support."));
//restart the server
$response = $this->pterodactyl->powerAction($server, 'restart');
if ($response->failed()) return redirect()->route('servers.index')->with('error', 'Upgrade Failed! Could not restart the server: ' . $response->json()['errors'][0]['detail']);
// Remove the allocation property from the server object as it is not a column in the database
unset($server->allocation);
@ -406,9 +410,6 @@ class ServerController extends Controller
// Withdraw the credits for the new product
$user->decrement('credits', $newProduct->price);
//restart the server
$response = $this->pterodactyl->powerAction($server, 'restart');
if ($response->failed()) return redirect()->route('servers.index')->with('error', 'Server upgraded successfully! Could not restart the server: ' . $response->json()['errors'][0]['detail']);
return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
} else {
return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('Not Enough Balance for Upgrade'));

View file

@ -201,12 +201,6 @@
{{ __('Databases') }}</span>
<span class="d-inline-block" x-text="product.databases"></span>
</li>
<li class="d-flex justify-content-between">
<span class="d-inline-block"><i class="fas fa-skull-crossbones"></i>
{{ __('OOM Killer') }}</span>
<span class="d-inline-block"
x-text="product.oom_killer == 1 ? 'enabled' : 'disabled'"></span>
</li>
<li class="d-flex justify-content-between">
<span class="d-inline-block"><i class="fas fa-network-wired"></i>
{{ __('Allocations') }}