Skip to content

Commit

Permalink
fix API
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarzin committed Nov 11, 2024
1 parent cd1a5f4 commit 84bdaa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 6 additions & 6 deletions app/Http/Controllers/API/LogicalServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', []));
}

Expand All @@ -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', []));
}

Expand Down
5 changes: 2 additions & 3 deletions app/Http/Controllers/API/PhysicalServerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 84bdaa0

Please sign in to comment.