diff --git a/app/Http/Controllers/API/ControlController.php b/app/Http/Controllers/API/ControlController.php index 89b8df05..2af4bc21 100644 --- a/app/Http/Controllers/API/ControlController.php +++ b/app/Http/Controllers/API/ControlController.php @@ -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); } @@ -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(); }