clqms-be/app/Models/AreaGeoModel.php
OpenCode Bot 9946978487 chore: refresh CLQMS backend baseline
Re-synced controllers, configs, libraries, seeds, and docs with the latest API expectations and response helpers.
2026-04-08 16:07:19 +07:00

40 lines
1003 B
PHP
Executable File

<?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();
}
}