fix getcities by parent

This commit is contained in:
mahdahar 2025-12-02 13:19:42 +07:00
parent 8767b823ca
commit 72002bd437
2 changed files with 6 additions and 2 deletions

View File

@ -37,7 +37,8 @@ class AreaGeo extends BaseController {
}
public function getCities() {
$rows = $this->model->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);

View File

@ -29,8 +29,11 @@ class AreaGeoModel extends BaseModel {
return $rows;
}
public function getCities() {
public function getCities($filter) {
$this->select('AreaGeoID, AreaName')->where('Parent > 0');
if(!empty($filter['Parent'])){
$this->where('Parent', $filter['Parent']);
}
return $this->findAll();
}