diff --git a/app/Http/Controllers/API/ControlController.php b/app/Http/Controllers/API/ControlController.php index accab936..89b8df05 100644 --- a/app/Http/Controllers/API/ControlController.php +++ b/app/Http/Controllers/API/ControlController.php @@ -24,6 +24,8 @@ 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', [])); return response()->json($control, 201); } @@ -40,6 +42,8 @@ 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', [])); return response()->json(); } diff --git a/app/Http/Controllers/API/MeasureController.php b/app/Http/Controllers/API/MeasureController.php index 7702e09d..a8082d81 100644 --- a/app/Http/Controllers/API/MeasureController.php +++ b/app/Http/Controllers/API/MeasureController.php @@ -24,6 +24,8 @@ public function store(Request $request) abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); $measure = Measure::create($request->all()); + if ($request->has('controls')) + $measure->controls()->sync($request->input('controls', [])); return response()->json($measure, 201); } @@ -40,6 +42,8 @@ public function update(Request $request, Measure $measure) abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); $measure->update($request->all()); + if ($request->has('controls')) + $measure->controls()->sync($request->input('controls', [])); return response()->json(); } diff --git a/app/Models/Control.php b/app/Models/Control.php index 705d3ff6..0ed34350 100644 --- a/app/Models/Control.php +++ b/app/Models/Control.php @@ -25,6 +25,15 @@ class Control extends Model ]; protected $fillable = [ + 'name', + 'objective', + 'observations', + 'input', + 'attributes', + 'model', + 'action_plan', + 'realisation_date', + 'plan_date', ]; // Control status : diff --git a/app/Models/Domain.php b/app/Models/Domain.php index cb87cf4c..b67f0e08 100644 --- a/app/Models/Domain.php +++ b/app/Models/Domain.php @@ -19,5 +19,8 @@ class Domain extends Model ]; protected $fillable = [ + 'title', + 'framework', + 'description', ]; } diff --git a/app/Models/Measure.php b/app/Models/Measure.php index 1e263e2f..e3197311 100644 --- a/app/Models/Measure.php +++ b/app/Models/Measure.php @@ -23,6 +23,12 @@ class Measure extends Model ]; protected $fillable = [ + 'name', + 'clause', + 'objective', + 'input', + 'attributes', + 'model', ]; // Return the domain associated to this measure diff --git a/docs/api.fr.md b/docs/api.fr.md index d6d37c6b..ec8156a2 100644 --- a/docs/api.fr.md +++ b/docs/api.fr.md @@ -87,7 +87,7 @@ Voici quelques exemples d'utilisation de l'API avec PHP : $token = json_decode($response)->token; } else { - error_log($responseInfo['http_code']); + error_log($response); error_log("No login api status 403"); } } diff --git a/docs/api.md b/docs/api.md index 9b0be980..498586ab 100644 --- a/docs/api.md +++ b/docs/api.md @@ -87,7 +87,7 @@ Here are a few examples of how to use the API with PHP: $token = json_decode($response)->token; } else { - error_log($responseInfo['http_code']); + error_log($response); error_log("No login api status 403"); } }