crm-summit/app/Models/ZonesModel.php

34 lines
860 B
PHP

<?php namespace App\Models;
use CodeIgniter\Model;
class ZonesModel extends Model {
protected $table = 'zones';
protected $primaryKey = 'zoneid';
protected $allowedFields = [ 'zonecode', 'zoneclass', 'parentzoneid', 'zonename' ];
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();
}
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();
}
}