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/
|
/results/
|
||||||
/phpunit*.xml
|
/phpunit*.xml
|
||||||
/public/.htaccess
|
/public/.htaccess
|
||||||
|
|
||||||
|
.serena/
|
||||||
@ -32,16 +32,21 @@ class AreaGeoController extends BaseController {
|
|||||||
|
|
||||||
public function getProvinces() {
|
public function getProvinces() {
|
||||||
$rows = $this->model->getProvinces();
|
$rows = $this->model->getProvinces();
|
||||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => '' ], 200); }
|
$transformed = array_map(function($row) {
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
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() {
|
public function getCities() {
|
||||||
$filter = [ 'Parent' => $this->request->getVar('Parent') ?? null ];
|
$filter = [ 'Parent' => $this->request->getVar('Parent') ?? null ];
|
||||||
$rows = $this->model->getCities($filter);
|
$rows = $this->model->getCities($filter);
|
||||||
|
$transformed = array_map(function($row) {
|
||||||
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => [] ], 200); }
|
return ['value' => $row['AreaGeoID'], 'label' => $row['AreaName']];
|
||||||
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
|
}, $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