update areageo endpoint to value and label

This commit is contained in:
mahdahar 2026-01-26 10:27:28 +07:00
parent 823694e4a1
commit f56200eb53
2 changed files with 12 additions and 5 deletions

2
.gitignore vendored
View File

@ -125,3 +125,5 @@ _modules/*
/results/
/phpunit*.xml
/public/.htaccess
.serena/

View File

@ -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);
}
}