| @@ 57-81 (lines=25) @@ | ||
| 54 | return view('admin.services.new'); |
|
| 55 | } |
|
| 56 | ||
| 57 | public function postNew(Request $request) |
|
| 58 | { |
|
| 59 | try { |
|
| 60 | $repo = new ServiceRepository\Service; |
|
| 61 | $service = $repo->create($request->only([ |
|
| 62 | 'name', |
|
| 63 | 'description', |
|
| 64 | 'file', |
|
| 65 | 'executable', |
|
| 66 | 'startup', |
|
| 67 | ])); |
|
| 68 | Alert::success('Successfully created new service!')->flash(); |
|
| 69 | ||
| 70 | return redirect()->route('admin.services.service', $service->id); |
|
| 71 | } catch (DisplayValidationException $ex) { |
|
| 72 | return redirect()->route('admin.services.new')->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 73 | } catch (DisplayException $ex) { |
|
| 74 | Alert::danger($ex->getMessage())->flash(); |
|
| 75 | } catch (\Exception $ex) { |
|
| 76 | Log::error($ex); |
|
| 77 | Alert::danger('An error occured while attempting to add a new service.')->flash(); |
|
| 78 | } |
|
| 79 | ||
| 80 | return redirect()->route('admin.services.new')->withInput(); |
|
| 81 | } |
|
| 82 | ||
| 83 | public function getService(Request $request, $service) |
|
| 84 | { |
|
| @@ 90-112 (lines=23) @@ | ||
| 87 | ]); |
|
| 88 | } |
|
| 89 | ||
| 90 | public function postService(Request $request, $service) |
|
| 91 | { |
|
| 92 | try { |
|
| 93 | $repo = new ServiceRepository\Service; |
|
| 94 | $repo->update($service, $request->only([ |
|
| 95 | 'name', |
|
| 96 | 'description', |
|
| 97 | 'file', |
|
| 98 | 'executable', |
|
| 99 | 'startup', |
|
| 100 | ])); |
|
| 101 | Alert::success('Successfully updated this service.')->flash(); |
|
| 102 | } catch (DisplayValidationException $ex) { |
|
| 103 | return redirect()->route('admin.services.service', $service)->withErrors(json_decode($ex->getMessage()))->withInput(); |
|
| 104 | } catch (DisplayException $ex) { |
|
| 105 | Alert::danger($ex->getMessage())->flash(); |
|
| 106 | } catch (\Exception $ex) { |
|
| 107 | Log::error($ex); |
|
| 108 | Alert::danger('An error occurred while attempting to update this service.')->flash(); |
|
| 109 | } |
|
| 110 | ||
| 111 | return redirect()->route('admin.services.service', $service)->withInput(); |
|
| 112 | } |
|
| 113 | ||
| 114 | public function deleteService(Request $request, $service) |
|
| 115 | { |
|