From f56200eb532ec791925fdd16a77ab77e2292301a Mon Sep 17 00:00:00 2001 From: mahdahar <89adham@gmail.com> Date: Mon, 26 Jan 2026 10:27:28 +0700 Subject: [PATCH] update areageo endpoint to value and label --- .gitignore | 2 ++ app/Controllers/AreaGeoController.php | 15 ++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 00a5c71..69c748b 100644 --- a/.gitignore +++ b/.gitignore @@ -125,3 +125,5 @@ _modules/* /results/ /phpunit*.xml /public/.htaccess + +.serena/ \ No newline at end of file diff --git a/app/Controllers/AreaGeoController.php b/app/Controllers/AreaGeoController.php index 2775469..c2f1797 100644 --- a/app/Controllers/AreaGeoController.php +++ b/app/Controllers/AreaGeoController.php @@ -32,16 +32,21 @@ class AreaGeoController extends BaseController { public function getProvinces() { $rows = $this->model->getProvinces(); - if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => '' ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + $transformed = array_map(function($row) { + return ['value' => $row['AreaGeoID'], 'label' => $row['AreaName']]; + }, $rows); + if (empty($transformed)) { return $this->respond([ 'status' => 'success', 'data' => [] ], 200); } + return $this->respond([ 'status' => 'success', 'data' => $transformed ], 200); } public function getCities() { $filter = [ 'Parent' => $this->request->getVar('Parent') ?? null ]; $rows = $this->model->getCities($filter); - - if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); } - return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200); + $transformed = array_map(function($row) { + return ['value' => $row['AreaGeoID'], 'label' => $row['AreaName']]; + }, $rows); + if (empty($transformed)) { return $this->respond([ 'status' => 'success', 'data' => [] ], 200); } + return $this->respond([ 'status' => 'success', 'data' => $transformed ], 200); } }