diff --git a/src/Modules/Retribusi/Frontend/RetribusiReadService.php b/src/Modules/Retribusi/Frontend/RetribusiReadService.php index 7131693..5c8123d 100644 --- a/src/Modules/Retribusi/Frontend/RetribusiReadService.php +++ b/src/Modules/Retribusi/Frontend/RetribusiReadService.php @@ -121,23 +121,25 @@ class RetribusiReadService * * @param int $page * @param int $limit + * @param string|null $locationCode Optional filter by location * @return array * @throws PDOException */ - public function getStreams(int $page, int $limit): array + public function getStreams(int $page, int $limit, ?string $locationCode = null): array { // Sementara stream = gate (alias) - return $this->getGates($page, $limit); + return $this->getGates($page, $limit, $locationCode); } /** * Get total count of streams * + * @param string|null $locationCode Optional filter by location * @return int * @throws PDOException */ - public function getStreamsTotal(): int + public function getStreamsTotal(?string $locationCode = null): int { - return $this->getGatesTotal(); + return $this->getGatesTotal($locationCode); } } diff --git a/src/Modules/Retribusi/Frontend/StreamController.php b/src/Modules/Retribusi/Frontend/StreamController.php index e4ab433..f3723c0 100644 --- a/src/Modules/Retribusi/Frontend/StreamController.php +++ b/src/Modules/Retribusi/Frontend/StreamController.php @@ -25,8 +25,16 @@ class StreamController $queryParams = $request->getQueryParams(); [$page, $limit] = Validator::validatePagination($queryParams); - $data = $this->service->getStreams($page, $limit); - $total = $this->service->getStreamsTotal(); + // Get location_code filter + $locationCode = $queryParams['location_code'] ?? null; + if ($locationCode !== null && (!is_string($locationCode) || trim($locationCode) === '')) { + $locationCode = null; + } else if ($locationCode !== null) { + $locationCode = trim($locationCode); + } + + $data = $this->service->getStreams($page, $limit, $locationCode); + $total = $this->service->getStreamsTotal($locationCode); return ResponseHelper::json( $response,