40 lines
964 B
PHP
40 lines
964 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 > 0');
|
|
if(!empty($filter['Parent'])){
|
|
$this->where('Parent', $filter['Parent']);
|
|
}
|
|
return $this->findAll();
|
|
}
|
|
|
|
} |