Fix server deletion mechanics

This commit is contained in:
Dane Everitt 2017-02-16 13:26:39 -05:00
parent 516e2dc5ee
commit 38feac9f0b
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53

View file

@ -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');