/** * Delete Server * * @Delete("/servers/{id}/{force}") * @Versions({"v1"}) * @Parameters({ * @Parameter("id", type="integer", required=true, description="The ID of the server."), * @Parameter("force", type="string", required=false, description="Use 'force' if the server should be removed regardless of daemon response."), * }) * @Response(204) */ public function delete(Request $request, $id, $force = null) { try { $server = new ServerRepository(); $server->deleteServer($id, $force); return $this->response->noContent(); } catch (DisplayException $ex) { throw new ResourceException($ex->getMessage()); } catch (\Exception $e) { throw new ServiceUnavailableHttpException('An error occured while attempting to delete this server.'); } }
public function deleteServer(Request $request, $id, $force = null) { try { $server = new ServerRepository(); $server->deleteServer($id, $force); Alert::success('Server was successfully deleted from the panel and the daemon.')->flash(); return redirect()->route('admin.servers'); } catch (DisplayException $ex) { Alert::danger($ex->getMessage())->flash(); } catch (\Exception $ex) { Log::error($ex); Alert::danger('An unhandled exception occured while attemping to delete this server. Please try again.')->flash(); } return redirect()->route('admin.servers.view', ['id' => $id, 'tab' => 'tab_delete']); }