clqms-be/app/Controllers/AreaGeo.php

47 lines
1.7 KiB
PHP
Raw Normal View History

2025-12-01 16:47:52 +07:00
<?php
namespace App\Controllers;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\AreaGeoModel;
class AreaGeo extends BaseController {
use ResponseTrait;
protected $model;
public function __construct() {
$this->model = new AreaGeoModel();
}
public function index() {
try {
2025-12-02 12:52:23 +07:00
$filters = [
'AreaGeoID' => $this->request->getVar('AreaGeoID') ?? null,
'AreaName' => $this->request->getVar('AreaName') ?? null
];
$rows = $this->model->getAreaGeos( $filters );
2025-12-01 16:47:52 +07:00
if(empty($rows)){return $this->respond(['status'=>'success', 'message'=>"no data found.", 'data'=>$rows], 200);}
return $this->respond(['status'=>'success', 'message'=>"data fetched successfully", 'data'=>$rows], 200);
} catch (\Exception $e) {
return $this->respond([ 'status' => 'error', 'message' => $e->getMessage() ], 200);
}
}
public function getProvinces() {
$rows = $this->model->getProvinces();
2025-12-02 12:52:23 +07:00
if (empty($rows)) { return $this->respond([ 'status' => 'success', 'message' => "data not found", 'data' => '' ], 200); }
2025-12-02 13:08:30 +07:00
return $this->respond([ 'status' => 'success', 'message'=> "Data fetched successfully", 'data' => $rows ], 200);
2025-12-01 16:47:52 +07:00
}
public function getCities() {
2025-12-02 13:19:42 +07:00
$filter = [ 'Parent' => $this->request->getVar('Parent') ?? null ];
$rows = $this->model->getCities($filter);
2025-12-01 16:47:52 +07:00
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);
}
}