42 lines
1000 B
PHP
42 lines
1000 B
PHP
<?php
|
|
namespace App\Models;
|
|
|
|
use App\Models\BaseModel;
|
|
|
|
class AreaGeoModel extends BaseModel {
|
|
protected $table = 'areageo';
|
|
protected $primaryKey = 'AreaGeoID';
|
|
protected $allowedFields = ['Parent', 'AreaCode', 'Class', 'AreaName'];
|
|
|
|
public function getAreaGeos() {
|
|
if (!empty($filters['AreaGeoID'])) {
|
|
$this->where('AreaGeoID', $filters['AreaGeoID']);
|
|
}
|
|
if (!empty($filters['AreaName'])) {
|
|
$this->like('AreaName', $filters['AreaName'], 'both');
|
|
}
|
|
|
|
return $this->findAll();
|
|
}
|
|
|
|
public function getProvinces() {
|
|
$rows = $this->select('AreaGeoID, AreaName')
|
|
->orGroupStart()
|
|
->where('Parent', null)
|
|
->orWhere('Parent', 0)
|
|
->groupEnd()->findAll();
|
|
|
|
return $rows;
|
|
}
|
|
|
|
public function getCities($filter = []) {
|
|
$this->select('AreaGeoID, AreaName')->where('Parent IS NOT NULL', null, false);
|
|
|
|
if (!empty($filter['AreaGeoID'])) {
|
|
$this->where('Parent', $filter['AreaGeoID']);
|
|
}
|
|
|
|
return $this->findAll();
|
|
}
|
|
|
|
} |