crm-summit/app/Models/ZonesModel.php

34 lines
860 B
PHP
Raw Normal View History

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
public function getAllProvinces() {
$this->select('zoneid, zonename')->where('parentzoneid IS NULL', null, false);
// if (!empty($filters['zoneid'])) {
// $this->where('zoneid', $filters['zoneid']);
// }
// if (!empty($filters['zonename'])) {
// $this->like('zonename', $filters['zonename'], 'both');
// }
return $this->findAll();
2025-10-21 15:27:22 +07:00
}
public function getAllCities($filter = []) {
$rows = $this->select('zoneid, zonename')->where('parentzoneid IS NOT NULL', null, false);
if (!empty($filter['zoneid'])) {
$this->where('parentzoneid', $filter['zoneid']);
}
return $this->findAll();
2025-10-21 15:27:22 +07:00
}
2024-04-24 13:20:52 +07:00
}