| @@ 388-409 (lines=22) @@ | ||
| 385 | * @param int $id |
|
| 386 | * @return \Illuminate\Response\RedirectResponse |
|
| 387 | */ |
|
| 388 | public function updateBuild(Request $request, $id) |
|
| 389 | { |
|
| 390 | $repo = new ServerRepository; |
|
| 391 | ||
| 392 | try { |
|
| 393 | $repo->changeBuild($id, $request->intersect([ |
|
| 394 | 'allocation_id', 'add_allocations', 'remove_allocations', |
|
| 395 | 'memory', 'swap', 'io', 'cpu', |
|
| 396 | ])); |
|
| 397 | ||
| 398 | Alert::success('Server details were successfully updated.')->flash(); |
|
| 399 | } catch (DisplayValidationException $ex) { |
|
| 400 | return redirect()->route('admin.servers.view.build', $id)->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 401 | } catch (DisplayException $ex) { |
|
| 402 | Alert::danger($ex->getMessage())->flash(); |
|
| 403 | } catch (\Exception $ex) { |
|
| 404 | Log::error($ex); |
|
| 405 | Alert::danger('An unhandled exception occured while attemping to add this server. This error has been logged.')->flash(); |
|
| 406 | } |
|
| 407 | ||
| 408 | return redirect()->route('admin.servers.view.build', $id); |
|
| 409 | } |
|
| 410 | ||
| 411 | /** |
|
| 412 | * Start the server deletion process. |
|
| @@ 93-114 (lines=22) @@ | ||
| 90 | * @param int $id The ID of the service option to assign this variable to. |
|
| 91 | * @return \Illuminate\Response\RedirectResponse |
|
| 92 | */ |
|
| 93 | public function createVariable(Request $request, $id) |
|
| 94 | { |
|
| 95 | $repo = new VariableRepository; |
|
| 96 | ||
| 97 | try { |
|
| 98 | $variable = $repo->create($id, $request->only([ |
|
| 99 | 'name', 'description', 'env_variable', |
|
| 100 | 'default_value', 'options', 'rules', |
|
| 101 | ])); |
|
| 102 | ||
| 103 | Alert::success('New variable successfully assigned to this service option.')->flash(); |
|
| 104 | } catch (DisplayValidationException $ex) { |
|
| 105 | return redirect()->route('admin.services.option.variables', $id)->withErrors(json_decode($ex->getMessage())); |
|
| 106 | } catch (DisplayException $ex) { |
|
| 107 | Alert::danger($ex->getMessage())->flash(); |
|
| 108 | } catch (\Exception $ex) { |
|
| 109 | Log::error($ex); |
|
| 110 | Alert::danger('An unhandled exception was encountered while attempting to process that request. This error has been logged.')->flash(); |
|
| 111 | } |
|
| 112 | ||
| 113 | return redirect()->route('admin.services.option.variables', $id); |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Display option overview page. |
|
| @@ 75-97 (lines=23) @@ | ||
| 72 | * @param Request $request |
|
| 73 | * @return \Illuminate\Response\RedirectResponse |
|
| 74 | */ |
|
| 75 | public function create(Request $request) |
|
| 76 | { |
|
| 77 | $repo = new DatabaseRepository; |
|
| 78 | ||
| 79 | try { |
|
| 80 | $host = $repo->add($request->intersect([ |
|
| 81 | 'name', 'username', 'password', |
|
| 82 | 'host', 'port', 'node_id', |
|
| 83 | ])); |
|
| 84 | Alert::success('Successfully created new database host on the system.')->flash(); |
|
| 85 | ||
| 86 | return redirect()->route('admin.databases.view', $host->id); |
|
| 87 | } catch (\PDOException $ex) { |
|
| 88 | Alert::danger($ex->getMessage())->flash(); |
|
| 89 | } catch (DisplayValidationException $ex) { |
|
| 90 | return redirect()->route('admin.databases')->withErrors(json_decode($ex->getMessage())); |
|
| 91 | } catch (\Exception $ex) { |
|
| 92 | Log::error($ex); |
|
| 93 | Alert::danger('An error was encountered while trying to process this request. This error has been logged.')->flash(); |
|
| 94 | } |
|
| 95 | ||
| 96 | return redirect()->route('admin.databases'); |
|
| 97 | } |
|
| 98 | ||
| 99 | /** |
|
| 100 | * Handle post request to update a database host. |
|