clqms-be/app/Models/AreaGeoModel.php

38 lines
932 B
PHP
Raw Normal View History

2025-12-01 16:47:52 +07:00
<?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();
}
}