update areageo endpoint to value and label
This commit is contained in:
parent
823694e4a1
commit
f56200eb53
2
.gitignore
vendored
2
.gitignore
vendored
@ -125,3 +125,5 @@ _modules/*
|
||||
/results/
|
||||
/phpunit*.xml
|
||||
/public/.htaccess
|
||||
|
||||
.serena/
|
||||
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user