From 38feac9f0b804c658fcc3d1d3e58655659c9433f Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 16 Feb 2017 13:26:39 -0500 Subject: [PATCH] Fix server deletion mechanics --- app/Repositories/ServerRepository.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/Repositories/ServerRepository.php b/app/Repositories/ServerRepository.php index a72512d3e..37c18a058 100644 --- a/app/Repositories/ServerRepository.php +++ b/app/Repositories/ServerRepository.php @@ -789,11 +789,13 @@ class ServerRepository // Remove Variables Models\ServerVariable::where('server_id', $server->id)->delete(); - // Remove Permissions (Foreign Key requires before Subusers) - Models\Permission::where('server_id', $server->id)->delete(); - // Remove SubUsers - Models\Subuser::where('server_id', $server->id)->delete(); + foreach(Models\Subuser::with('permissions')->where('server_id', $server->id)->get() as &$subuser) { + foreach($subuser->permissions as &$permission) { + $permission->delete(); + } + $subuser->delete(); + } // Remove Downloads Models\Download::where('server', $server->uuid)->delete(); @@ -809,7 +811,7 @@ class ServerRepository $repository->drop($database->id); } - $server->node->guzzleRequest([ + $server->node->guzzleClient([ 'X-Access-Token' => $server->node->daemonSecret, 'X-Access-Server' => $server->uuid, ])->request('DELETE', '/servers');