| @@ 61-84 (lines=24) @@ | ||
| 58 | * @param \Illuminate\Http\Request $request |
|
| 59 | * @return \Illuminate\Response\RedirectResponse |
|
| 60 | */ |
|
| 61 | public function store(Request $request) |
|
| 62 | { |
|
| 63 | $repo = new OptionRepository; |
|
| 64 | ||
| 65 | try { |
|
| 66 | $option = $repo->create($request->intersect([ |
|
| 67 | 'service_id', 'name', 'description', 'tag', |
|
| 68 | 'docker_image', 'startup', 'config_from', 'config_startup', |
|
| 69 | 'config_logs', 'config_files', 'config_stop', |
|
| 70 | ])); |
|
| 71 | Alert::success('Successfully created new service option.')->flash(); |
|
| 72 | ||
| 73 | return redirect()->route('admin.services.option.view', $option->id); |
|
| 74 | } catch (DisplayValidationException $ex) { |
|
| 75 | return redirect()->route('admin.services.option.new')->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 76 | } catch (DisplayException $ex) { |
|
| 77 | Alert::danger($ex->getMessage())->flash(); |
|
| 78 | } catch (\Exception $ex) { |
|
| 79 | Log::error($ex); |
|
| 80 | Alert::danger('An unhandled exception occurred while attempting to create this service. This error has been logged.')->flash(); |
|
| 81 | } |
|
| 82 | ||
| 83 | return redirect()->route('admin.services.option.new')->withInput(); |
|
| 84 | } |
|
| 85 | ||
| 86 | /** |
|
| 87 | * Handles POST request to create a new option variable. |
|
| @@ 81-108 (lines=28) @@ | ||
| 78 | * @param \Illuminate\Http\Request $request |
|
| 79 | * @return \Illuminate\Http\RedirectResponse |
|
| 80 | */ |
|
| 81 | public function store(Request $request) |
|
| 82 | { |
|
| 83 | try { |
|
| 84 | $repo = new NodeRepository; |
|
| 85 | $node = $repo->create(array_merge( |
|
| 86 | $request->only([ |
|
| 87 | 'public', 'disk_overallocate', 'memory_overallocate', |
|
| 88 | ]), |
|
| 89 | $request->intersect([ |
|
| 90 | 'name', 'location_id', 'fqdn', |
|
| 91 | 'scheme', 'memory', 'disk', |
|
| 92 | 'daemonBase', 'daemonSFTP', 'daemonListen', |
|
| 93 | ]) |
|
| 94 | )); |
|
| 95 | Alert::success('Successfully created new node that can be configured automatically on your remote machine by visiting the configuration tab. <strong>Before you can add any servers you need to first assign some IP addresses and ports.</strong>')->flash(); |
|
| 96 | ||
| 97 | return redirect()->route('admin.nodes.view', $node->id); |
|
| 98 | } catch (DisplayValidationException $e) { |
|
| 99 | return redirect()->route('admin.nodes.new')->withErrors(json_decode($e->getMessage()))->withInput(); |
|
| 100 | } catch (DisplayException $e) { |
|
| 101 | Alert::danger($e->getMessage())->flash(); |
|
| 102 | } catch (\Exception $e) { |
|
| 103 | Log::error($e); |
|
| 104 | Alert::danger('An unhandled exception occured while attempting to add this node. Please try again.')->flash(); |
|
| 105 | } |
|
| 106 | ||
| 107 | return redirect()->route('admin.nodes.new')->withInput(); |
|
| 108 | } |
|
| 109 | ||
| 110 | /** |
|
| 111 | * Shows the index overview page for a specific node. |
|