47 lines
1.6 KiB
PHP
Raw Permalink Normal View History

2025-10-21 15:27:22 +07:00
<?php
namespace App\Controllers\Api;
use CodeIgniter\API\ResponseTrait;
use App\Controllers\BaseController;
use App\Models\ZonesModel;
class ZonesApi extends BaseController {
use ResponseTrait;
protected $model;
public function __construct() {
$this->model = new ZonesModel();
}
public function getAll() {
$rows = $this->model->getAll();
2025-10-21 15:27:22 +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);
2025-10-21 15:27:22 +07:00
}
// public function getProvinces() {
// // $filters = [
// // 'zoneid' => $this->request->getVar('zoneid') ?? null,
// // 'zonename' => $this->request->getVar('zonename') ?? null
// // ];
// $rows = $this->model->getAllProvinces();
// 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);
// }
// public function getCities() {
2025-10-21 15:27:22 +07:00
// $filter = [
// 'zoneid' => $this->request->getVar('zoneid') ?? null
// ];
// $rows = $this->model->getAllCities($filter);
2025-10-21 15:27:22 +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);
// }
2025-10-21 15:27:22 +07:00
}