From cd1a5f456dacdd656779227842b323c0513945a3 Mon Sep 17 00:00:00 2001 From: didier Date: Mon, 11 Nov 2024 18:48:29 +0100 Subject: [PATCH 1/2] fix api --- app/Http/Controllers/API/PhysicalServerController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/API/PhysicalServerController.php b/app/Http/Controllers/API/PhysicalServerController.php index 8a43b459..002a3eae 100644 --- a/app/Http/Controllers/API/PhysicalServerController.php +++ b/app/Http/Controllers/API/PhysicalServerController.php @@ -34,11 +34,11 @@ public function store(StorePhysicalServerRequest $request) return response()->json($physicalserver, 201); } - public function show(PhysicalServer $physicalserver) + public function show(PhysicalServer $physicalServer) { abort_if(Gate::denies('physical_server_show'), Response::HTTP_FORBIDDEN, '403 Forbidden'); - return new PhysicalServerResource($physicalserver); + return new PhysicalServerResource($physicalServer); } public function update(UpdatePhysicalServerRequest $request, PhysicalServer $physicalServer) From 84bdaa0a652c56600031f7bff1862572aef385e5 Mon Sep 17 00:00:00 2001 From: didier Date: Mon, 11 Nov 2024 22:18:52 +0100 Subject: [PATCH 2/2] fix API --- app/Http/Controllers/API/LogicalServerController.php | 12 ++++++------ .../Controllers/API/PhysicalServerController.php | 5 ++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/app/Http/Controllers/API/LogicalServerController.php b/app/Http/Controllers/API/LogicalServerController.php index 730e27f7..186fe3d5 100644 --- a/app/Http/Controllers/API/LogicalServerController.php +++ b/app/Http/Controllers/API/LogicalServerController.php @@ -27,13 +27,13 @@ public function store(StoreLogicalServerRequest $request) abort_if(Gate::denies('logical_server_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $logicalServer = LogicalServer::create($request->all()); - if ($request->has('servers[]')) { + if ($request->has('servers')) { $logicalServer->servers()->sync($request->input('servers', [])); } - if ($request->has('applications[]')) { + if ($request->has('applications')) { $logicalServer->applications()->sync($request->input('applications', [])); } - if ($request->has('databases[]')) { + if ($request->has('databases')) { $logicalServer->databases()->sync($request->input('databases', [])); } @@ -52,13 +52,13 @@ public function update(UpdateLogicalServerRequest $request, LogicalServer $logic abort_if(Gate::denies('logical_server_edit'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $logicalServer->update($request->all()); - if ($request->has('servers[]')) { + if ($request->has('servers')) { $logicalServer->servers()->sync($request->input('servers', [])); } - if ($request->has('applications[]')) { + if ($request->has('applications')) { $logicalServer->applications()->sync($request->input('applications', [])); } - if ($request->has('databases[]')) { + if ($request->has('databases')) { $logicalServer->databases()->sync($request->input('databases', [])); } diff --git a/app/Http/Controllers/API/PhysicalServerController.php b/app/Http/Controllers/API/PhysicalServerController.php index 002a3eae..959fbb22 100644 --- a/app/Http/Controllers/API/PhysicalServerController.php +++ b/app/Http/Controllers/API/PhysicalServerController.php @@ -27,9 +27,8 @@ public function store(StorePhysicalServerRequest $request) abort_if(Gate::denies('physical_server_create'), Response::HTTP_FORBIDDEN, '403 Forbidden'); $physicalserver = PhysicalServer::create($request->all()); - $physicalserver->applications()->sync($request->input('applications', [])); - // syncs - // $physicalserver->roles()->sync($request->input('roles', [])); + if ($request->has('applications')) + $physicalserver->applications()->sync($request->input('applications', [])); return response()->json($physicalserver, 201); }