| @@ 106-134 (lines=29) @@ | ||
| 103 | * @param int $id |
|
| 104 | * @return \Illuminate\Response\RedirectResponse |
|
| 105 | */ |
|
| 106 | public function update(Request $request, $id) |
|
| 107 | { |
|
| 108 | $repo = new DatabaseRepository; |
|
| 109 | ||
| 110 | try { |
|
| 111 | if ($request->input('action') !== 'delete') { |
|
| 112 | $host = $repo->update($id, $request->intersect([ |
|
| 113 | 'name', 'username', 'password', |
|
| 114 | 'host', 'port', 'node_id', |
|
| 115 | ])); |
|
| 116 | Alert::success('Database host was updated successfully.')->flash(); |
|
| 117 | } else { |
|
| 118 | $repo->delete($id); |
|
| 119 | ||
| 120 | return redirect()->route('admin.databases'); |
|
| 121 | } |
|
| 122 | } catch (\PDOException $ex) { |
|
| 123 | Alert::danger($ex->getMessage())->flash(); |
|
| 124 | } catch (DisplayException $ex) { |
|
| 125 | Alert::danger($ex->getMessage())->flash(); |
|
| 126 | } catch (DisplayValidationException $ex) { |
|
| 127 | return redirect()->route('admin.databases.view', $id)->withErrors(json_decode($ex->getMessage())); |
|
| 128 | } catch (\Exception $ex) { |
|
| 129 | Log::error($ex); |
|
| 130 | Alert::danger('An error was encountered while trying to process this request. This error has been logged.')->flash(); |
|
| 131 | } |
|
| 132 | ||
| 133 | return redirect()->route('admin.databases.view', $id); |
|
| 134 | } |
|
| 135 | } |
|
| 136 | ||
| @@ 139-166 (lines=28) @@ | ||
| 136 | * @param int $id |
|
| 137 | * @return \Illuminate\Response\RedirectResponse |
|
| 138 | */ |
|
| 139 | public function update(Request $request, $id) |
|
| 140 | { |
|
| 141 | $repo = new PackRepository; |
|
| 142 | ||
| 143 | try { |
|
| 144 | if ($request->input('action') !== 'delete') { |
|
| 145 | $pack = $repo->update($id, $request->intersect([ |
|
| 146 | 'name', 'description', 'version', |
|
| 147 | 'option_id', 'selectable', 'visible', 'locked', |
|
| 148 | ])); |
|
| 149 | Alert::success('Pack successfully updated.')->flash(); |
|
| 150 | } else { |
|
| 151 | $repo->delete($id); |
|
| 152 | Alert::success('Pack was successfully deleted from the system.')->flash(); |
|
| 153 | ||
| 154 | return redirect()->route('admin.packs'); |
|
| 155 | } |
|
| 156 | } catch (DisplayValidationException $ex) { |
|
| 157 | return redirect()->route('admin.packs.view', $id)->withErrors(json_decode($ex->getMessage())); |
|
| 158 | } catch (DisplayException $ex) { |
|
| 159 | Alert::danger($ex->getMessage())->flash(); |
|
| 160 | } catch (\Exception $ex) { |
|
| 161 | Log::error($ex); |
|
| 162 | Alert::danger('An error occured while attempting to edit this service pack. This error has been logged.')->flash(); |
|
| 163 | } |
|
| 164 | ||
| 165 | return redirect()->route('admin.packs.view', $id); |
|
| 166 | } |
|
| 167 | ||
| 168 | /** |
|
| 169 | * Creates an archive of the pack and downloads it to the browser. |
|