diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php b/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php index 49abac5f4..46af062ff 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/ValidationService.php @@ -12,6 +12,7 @@ class ValidationService public static function validateServiceLocationCombination(int $officeId, array $serviceIds): array { + $availableServices = ZmsApiFacadeService::getServicesProvidedAtOffice($officeId); $availableServiceIds = array_map(function ($service) { return $service['id']; diff --git a/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php b/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php index 7535c365f..8801048ac 100644 --- a/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php +++ b/zmscitizenapi/src/Zmscitizenapi/Services/ZmsApiFacadeService.php @@ -357,34 +357,34 @@ public static function getServicesByOfficeIds(array $officeIds): array * */ - public static function getServicesProvidedAtOffice(int $officeId): array - { - - $requestRelationList = ZmsApiClientService::getRequestRelationList(); - - $requestRelationArray = []; - foreach ($requestRelationList as $relation) { - $requestRelationArray[] = $relation; - } - - $serviceIds = array_filter($requestRelationArray, function ($relation) use ($officeId) { - return $relation->provider->id === $officeId; - }); - - $serviceIds = array_map(function ($relation) { - return $relation->request->id; - }, $serviceIds); - - $requestList = ZmsApiClientService::getServices() ?? []; - $requestArray = []; - foreach ($requestList as $request) { - $requestArray[] = $request; - } - - return array_filter($requestArray, function ($request) use ($serviceIds) { - return in_array($request->id, $serviceIds); - }); - } + public static function getServicesProvidedAtOffice(int $officeId): array + { + $requestRelationList = ZmsApiClientService::getRequestRelationList(); + + $requestRelationArray = []; + foreach ($requestRelationList as $relation) { + $requestRelationArray[] = $relation; + } + + $serviceIds = array_filter($requestRelationArray, function ($relation) use ($officeId) { + return $relation->provider->id === $officeId || (string)$relation->provider->id === (string)$officeId; + }); + + $serviceIds = array_map(function ($relation) { + return $relation->request->id; + }, $serviceIds); + + $requestList = ZmsApiClientService::getServices() ?? []; + $requestArray = []; + foreach ($requestList as $request) { + $requestArray[] = $request; + } + + return array_filter($requestArray, function ($request) use ($serviceIds) { + return in_array($request->id, $serviceIds); + }); + } + public static function getBookableFreeDays(array $queryParams): array {