isSuspended()) { return; } // Check if the server is currently being transferred. if (!is_null($server->transfer)) { throw new ConflictHttpException('Cannot toggle suspension status on a server that is currently being transferred.'); } // Update the server's suspension status. $server->update([ 'status' => $isSuspending ? Server::STATUS_SUSPENDED : null, ]); try { // Tell wings to re-sync the server state. $this->daemonServerRepository->setServer($server)->sync(); } catch (\Exception $exception) { // Rollback the server's suspension status if wings fails to sync the server. $server->update([ 'status' => $isSuspending ? null : Server::STATUS_SUSPENDED, ]); throw $exception; } } }