Skip to content

Commit

Permalink
Merge pull request #189 from dbarzin/dev
Browse files Browse the repository at this point in the history
add owners in controls API
  • Loading branch information
dbarzin authored Oct 16, 2024
2 parents bac4d42 + bfaf3a9 commit 1cc6126
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/Http/Controllers/API/ControlController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,13 @@ public function store(Request $request)
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden');

$control = Control::create($request->all());

if ($request->has('measures'))
$control->measures()->sync($request->input('measures', []));

if ($request->has('owners'))
$control->owners()->sync($request->input('owners', []));

return response()->json($control, 201);
}

Expand All @@ -42,9 +46,13 @@ public function update(Request $request, Control $control)
abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden');

$control->update($request->all());

if ($request->has('measures'))
$control->measures()->sync($request->input('measures', []));

if ($request->has('owners'))
$control->owners()->sync($request->input('owners', []));

return response()->json();
}

Expand Down

0 comments on commit 1cc6126

Please sign in to comment.