| @@ 152-171 (lines=20) @@ | ||
| 149 | * @param int $id |
|
| 150 | * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse |
|
| 151 | */ |
|
| 152 | public function delete(Request $request, $id) |
|
| 153 | { |
|
| 154 | $this->authorize('node-delete', $request->apiKey()); |
|
| 155 | ||
| 156 | $repo = new NodeRepository; |
|
| 157 | try { |
|
| 158 | $repo->delete($id); |
|
| 159 | ||
| 160 | return response('', 204); |
|
| 161 | } catch (DisplayException $ex) { |
|
| 162 | return response()->json([ |
|
| 163 | 'error' => $ex->getMessage(), |
|
| 164 | ], 400); |
|
| 165 | } catch (\Exception $ex) { |
|
| 166 | Log::error($ex); |
|
| 167 | ||
| 168 | return response()->json([ |
|
| 169 | 'error' => 'An unhandled exception occured while attemping to delete this node. Please try again.', |
|
| 170 | ], 500); |
|
| 171 | } |
|
| 172 | } |
|
| 173 | } |
|
| 174 | ||
| @@ 251-270 (lines=20) @@ | ||
| 248 | * @param int $id |
|
| 249 | * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse |
|
| 250 | */ |
|
| 251 | public function install(Request $request, $id) |
|
| 252 | { |
|
| 253 | $this->authorize('server-install', $request->apiKey()); |
|
| 254 | ||
| 255 | $repo = new ServerRepository; |
|
| 256 | try { |
|
| 257 | $repo->toggleInstall($id); |
|
| 258 | ||
| 259 | return response('', 204); |
|
| 260 | } catch (DisplayException $ex) { |
|
| 261 | return response()->json([ |
|
| 262 | 'error' => $ex->getMessage(), |
|
| 263 | ], 400); |
|
| 264 | } catch (\Exception $ex) { |
|
| 265 | Log::error($ex); |
|
| 266 | ||
| 267 | return response()->json([ |
|
| 268 | 'error' => 'An unhandled exception occured while attemping to toggle the install status for this server. Please try again.', |
|
| 269 | ], 500); |
|
| 270 | } |
|
| 271 | } |
|
| 272 | ||
| 273 | /** |
|
| @@ 163-182 (lines=20) @@ | ||
| 160 | * @param int $id |
|
| 161 | * @return \Illuminate\Http\Response|\Illuminate\Http\JsonResponse |
|
| 162 | */ |
|
| 163 | public function delete(Request $request, $id) |
|
| 164 | { |
|
| 165 | $this->authorize('user-delete', $request->apiKey()); |
|
| 166 | ||
| 167 | $repo = new UserRepository; |
|
| 168 | try { |
|
| 169 | $repo->delete($id); |
|
| 170 | ||
| 171 | return response('', 204); |
|
| 172 | } catch (DisplayException $ex) { |
|
| 173 | return response()->json([ |
|
| 174 | 'error' => $ex->getMessage(), |
|
| 175 | ], 400); |
|
| 176 | } catch (\Exception $ex) { |
|
| 177 | Log::error($ex); |
|
| 178 | ||
| 179 | return response()->json([ |
|
| 180 | 'error' => 'An unhandled exception occured while attemping to delete this user. Please try again.', |
|
| 181 | ], 500); |
|
| 182 | } |
|
| 183 | } |
|
| 184 | } |
|
| 185 | ||