/** * Create Server * * @Post("/servers") * @Versions({"v1"}) * @Response(201) */ public function create(Request $request) { try { $server = new ServerRepository(); $new = $server->create($request->all()); return $this->response->created(route('api.servers.view', ['id' => $new])); } catch (DisplayValidationException $ex) { throw new ResourceException('A validation error occured.', json_decode($ex->getMessage(), true)); } catch (DisplayException $ex) { throw new ResourceException($ex->getMessage()); } catch (\Exception $ex) { Log::error($ex); throw new BadRequestHttpException('There was an error while attempting to add this server to the system.'); } }
public function postNewServer(Request $request) { try { $server = new ServerRepository(); $response = $server->create($request->all()); return redirect()->route('admin.servers.view', ['id' => $response]); } catch (DisplayValidationException $ex) { return redirect()->route('admin.servers.new')->withErrors(json_decode($ex->getMessage()))->withInput(); } catch (DisplayException $ex) { Alert::danger($ex->getMessage())->flash(); return redirect()->route('admin.servers.new')->withInput(); } catch (\Exception $ex) { Log::error($ex); Alert::danger('An unhandled exception occured while attemping to add this server. Please try again.')->flash(); return redirect()->route('admin.servers.new')->withInput(); } }