Przeglądaj źródła

Fix Server upgrade || fix server overview total credits

Dennis 2 lat temu
rodzic
commit
b330e5a617

+ 1 - 1
app/Http/Controllers/Admin/OverViewController.php

@@ -38,7 +38,7 @@ class OverViewController extends Controller
         $counters = collect();
         $counters = collect();
         //Set basic variables in the collection
         //Set basic variables in the collection
         $counters->put('users', User::query()->count());
         $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('payments', Payment::query()->count());
         $counters->put('eggs', Egg::query()->count());
         $counters->put('eggs', Egg::query()->count());
         $counters->put('nests', Nest::query()->count());
         $counters->put('nests', Nest::query()->count());

+ 4 - 3
app/Http/Controllers/ServerController.php

@@ -389,6 +389,10 @@ class ServerController extends Controller
             $server->allocation = $serverAttributes['allocation'];
             $server->allocation = $serverAttributes['allocation'];
             $response = $this->pterodactyl->updateServer($server, $newProduct);
             $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."));
             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
             // Remove the allocation property from the server object as it is not a column in the database
             unset($server->allocation);
             unset($server->allocation);
@@ -406,9 +410,6 @@ class ServerController extends Controller
             // Withdraw the credits for the new product
             // Withdraw the credits for the new product
             $user->decrement('credits', $newProduct->price);
             $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'));
             return redirect()->route('servers.show', ['server' => $server->id])->with('success', __('Server Successfully Upgraded'));
         } else {
         } else {
             return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('Not Enough Balance for Upgrade'));
             return redirect()->route('servers.show', ['server' => $server->id])->with('error', __('Not Enough Balance for Upgrade'));

+ 0 - 6
themes/default/views/servers/create.blade.php

@@ -201,12 +201,6 @@
                                                         {{ __('Databases') }}</span>
                                                         {{ __('Databases') }}</span>
                                                     <span class="d-inline-block" x-text="product.databases"></span>
                                                     <span class="d-inline-block" x-text="product.databases"></span>
                                                 </li>
                                                 </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">
                                                 <li class="d-flex justify-content-between">
                                                     <span class="d-inline-block"><i class="fas fa-network-wired"></i>
                                                     <span class="d-inline-block"><i class="fas fa-network-wired"></i>
                                                         {{ __('Allocations') }}
                                                         {{ __('Allocations') }}