2024-04-24 13:20:52 +07:00
|
|
|
<?php namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
|
|
|
|
|
|
class ZonesModel extends Model {
|
2025-10-21 15:27:22 +07:00
|
|
|
|
2024-04-24 13:20:52 +07:00
|
|
|
protected $table = 'zones';
|
|
|
|
|
protected $primaryKey = 'zoneid';
|
|
|
|
|
protected $allowedFields = [ 'zonecode', 'zoneclass', 'parentzoneid', 'zonename' ];
|
2025-10-21 15:27:22 +07:00
|
|
|
|
2025-10-22 10:23:46 +07:00
|
|
|
public function getAllProvinces() {
|
2025-10-22 10:09:31 +07:00
|
|
|
$this->select('zoneid, zonename')->where('parentzoneid IS NULL', null, false);
|
|
|
|
|
|
2025-10-22 10:23:46 +07:00
|
|
|
// if (!empty($filters['zoneid'])) {
|
|
|
|
|
// $this->where('zoneid', $filters['zoneid']);
|
|
|
|
|
// }
|
|
|
|
|
// if (!empty($filters['zonename'])) {
|
|
|
|
|
// $this->like('zonename', $filters['zonename'], 'both');
|
|
|
|
|
// }
|
2025-10-22 10:09:31 +07:00
|
|
|
|
|
|
|
|
return $this->findAll();
|
2025-10-21 15:27:22 +07:00
|
|
|
}
|
|
|
|
|
|
2025-10-22 10:23:46 +07:00
|
|
|
public function getAllCities($filter = []) {
|
2025-10-22 10:09:31 +07:00
|
|
|
$rows = $this->select('zoneid, zonename')->where('parentzoneid IS NOT NULL', null, false);
|
|
|
|
|
|
2025-10-22 10:23:46 +07:00
|
|
|
if (!empty($filter['zoneid'])) {
|
|
|
|
|
$this->where('parentzoneid', $filter['zoneid']);
|
2025-10-22 10:09:31 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->findAll();
|
2025-10-21 15:27:22 +07:00
|
|
|
}
|
|
|
|
|
|
2024-04-24 13:20:52 +07:00
|
|
|
}
|