diff --git a/app/Http/Controllers/API/UserController.php b/app/Http/Controllers/API/UserController.php new file mode 100644 index 00000000..a1e1be23 --- /dev/null +++ b/app/Http/Controllers/API/UserController.php @@ -0,0 +1,55 @@ +role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); + + $users = User::all(); + + return response()->json($users); + } + + public function store(Request $request) + { + abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); + + $user = Document::create($user->all()); + + return response()->json($user, 201); + } + + public function show(User $user) + { + abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); + + return response()->json($user); + } + + public function update(Request $request, User $user) + { + abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); + + $user->update($request->all()); + + return response()->json(); + } + + public function destroy(User $user) + { + abort_if(Auth::User()->role !== 4, Response::HTTP_FORBIDDEN, '403 Forbidden'); + + $user->delete(); + + return response()->json(); + } +} diff --git a/app/Models/Control.php b/app/Models/Control.php index 0ed34350..81f92d09 100644 --- a/app/Models/Control.php +++ b/app/Models/Control.php @@ -34,6 +34,7 @@ class Control extends Model 'action_plan', 'realisation_date', 'plan_date', + 'periodicity' ]; // Control status : diff --git a/app/Models/Measure.php b/app/Models/Measure.php index e3197311..8b7a98a0 100644 --- a/app/Models/Measure.php +++ b/app/Models/Measure.php @@ -29,6 +29,7 @@ class Measure extends Model 'input', 'attributes', 'model', + 'periodicity' ]; // Return the domain associated to this measure diff --git a/docs/api.fr.md b/docs/api.fr.md index ec8156a2..3eb852fd 100644 --- a/docs/api.fr.md +++ b/docs/api.fr.md @@ -26,6 +26,8 @@ L'environnement Docker prend en charge cette fonctionnalité nativement, via l'[ - /api/controls +- /api/users + - /api/documents ### Actions gérées par le contrôleur de ressources diff --git a/docs/api.md b/docs/api.md index 498586ab..d8651029 100644 --- a/docs/api.md +++ b/docs/api.md @@ -26,6 +26,8 @@ The Docker environment supports this functionality natively, via the [entrypoint - /api/controls +- /api/users + - /api/documents ### Actions managed by the resource controller diff --git a/routes/api.php b/routes/api.php index bce2da53..a51da979 100644 --- a/routes/api.php +++ b/routes/api.php @@ -23,5 +23,6 @@ Route::apiResource('controls', ControlController::class); Route::apiResource('attributes', AttributeController::class); Route::apiResource('documents', DocumentController::class); + Route::apiResource('users', UserController::class); }); });