38 lines
932 B
PHP
38 lines
932 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() {
|
||
|
|
return $this->findAll();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getProvinces() {
|
||
|
|
$this->select('AreaGeoID, AreaName')->where('Parent IS NULL', null, false);
|
||
|
|
|
||
|
|
if (!empty($filters['AreaGeoID'])) {
|
||
|
|
$this->where('AreaGeoID', $filters['AreaGeoID']);
|
||
|
|
}
|
||
|
|
if (!empty($filters['AreaName'])) {
|
||
|
|
$this->like('AreaName', $filters['AreaName'], 'both');
|
||
|
|
}
|
||
|
|
|
||
|
|
return $this->findAll();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getCities($filter = []) {
|
||
|
|
$rows = $this->select('AreaGeoID, AreaName')->where('Parent IS NOT NULL', null, false);
|
||
|
|
|
||
|
|
if (!empty($filter['AreaGeoID'])) {
|
||
|
|
$this->where('Parent', $filter['AreaGeoID']);
|
||
|
|
}
|
||
|
|
|
||
|
|
return $this->findAll();
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|