| @@ 69-86 (lines=18) @@ | ||
| 66 | * @param \Illuminate\Http\Request $request |
|
| 67 | * @return \Illuminate\Http\RedirectResponse |
|
| 68 | */ |
|
| 69 | public function create(Request $request) |
|
| 70 | { |
|
| 71 | $repo = new LocationRepository; |
|
| 72 | ||
| 73 | try { |
|
| 74 | $location = $repo->create($request->intersect(['short', 'long'])); |
|
| 75 | Alert::success('Location was created successfully.')->flash(); |
|
| 76 | ||
| 77 | return redirect()->route('admin.locations.view', $location->id); |
|
| 78 | } catch (DisplayValidationException $ex) { |
|
| 79 | return redirect()->route('admin.locations')->withErrors(json_decode($ex->getMessage())); |
|
| 80 | } catch (\Exception $ex) { |
|
| 81 | Log::error($ex); |
|
| 82 | Alert::error('An unhandled exception occurred while processing this request. This error has been logged.')->flash(); |
|
| 83 | } |
|
| 84 | ||
| 85 | return redirect()->route('admin.locations'); |
|
| 86 | } |
|
| 87 | ||
| 88 | /** |
|
| 89 | * Handle request to update or delete location. |
|
| @@ 231-248 (lines=18) @@ | ||
| 228 | * @param int $id |
|
| 229 | * @return \Illuminate\Response\RedirectResponse |
|
| 230 | */ |
|
| 231 | public function updateScripts(Request $request, $id) |
|
| 232 | { |
|
| 233 | $repo = new OptionRepository; |
|
| 234 | ||
| 235 | try { |
|
| 236 | $repo->scripts($id, $request->only([ |
|
| 237 | 'script_install', 'script_entry', 'script_container', |
|
| 238 | ])); |
|
| 239 | Alert::success('Successfully updated option scripts to be run when servers are installed.')->flash(); |
|
| 240 | } catch (DisplayValidationException $ex) { |
|
| 241 | return redirect()->route('admin.services.option.scripts', $id)->withErrors(json_decode($ex->getMessage())); |
|
| 242 | } catch (\Exception $ex) { |
|
| 243 | Log::error($ex); |
|
| 244 | Alert::danger('An unhandled exception was encountered while attempting to process that request. This error has been logged.')->flash(); |
|
| 245 | } |
|
| 246 | ||
| 247 | return redirect()->route('admin.services.option.scripts', $id); |
|
| 248 | } |
|
| 249 | } |
|
| 250 | ||