Add /guest/departments endpoint for paginated department retrieval
- Introduced `GET /guest/departments` in `guestRoute` to fetch departments with pagination. - Limited response to include only `id` and `name` fields for streamlined output.
This commit is contained in:
@@ -5,6 +5,7 @@ namespace routes;
|
||||
use classes\authentication;
|
||||
use classes\recaptcha;
|
||||
use classes\virkdata;
|
||||
use objects\departments_o;
|
||||
use objects\logs_o;
|
||||
use objects\tokens_o;
|
||||
use objects\users_o;
|
||||
@@ -47,5 +48,17 @@ class guestRoute
|
||||
}, [
|
||||
'cvr_search' => 'Search CVR numbers'
|
||||
]);
|
||||
|
||||
$this->get('/guest/departments', function () {
|
||||
global $response;
|
||||
$departments = (new departments_o());
|
||||
$response->success($departments->listObjectsWithPaginationIfSet(function ($department_array) {
|
||||
// Only return id and name
|
||||
return [
|
||||
'id' => $department_array['id'],
|
||||
'name' => $department_array['name']
|
||||
];
|
||||
}), 200);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user