clqms-be/app/Models/ValueSet/ValueSetModel.php
2025-10-14 16:54:43 +07:00

48 lines
1.3 KiB
PHP

<?php
namespace App\Models\ValueSet;
use App\Models\BaseUtcModel;
class ValueSetModel extends BaseUtcModel {
protected $table = 'valueset';
protected $primaryKey = 'VID';
protected $allowedFields = ['SiteID', 'VSetID', 'VOrder', 'VValue', 'VDesc', 'VCategory', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
protected $beforeInsert = ['normalizeDatesToUTC'];
protected $beforeUpdate = ['normalizeDatesToUTC'];
protected $afterFind = ['convertDatesToUTCISO'];
protected $afterInsert = ['convertDatesToUTCISO'];
protected $afterUpdate = ['convertDatesToUTCISO'];
public function getValueSets($param = null) {
if ($param !== null) {
$builder = $this->builder();
$builder->groupStart()
->like('VValue', $param, 'both')
->orlike('VDesc', $param, 'both')
->groupEnd();
$rows = $builder->get()->getResultArray();
return $rows;
} else {
return $this->findAll();
}
}
public function getValueSet($VID) {
$rows = $this->select("valueset.*, valuesetdef.VSName")
->join('valuesetdef', 'valuesetdef.VSetID = valueset.VSetID', 'LEFT')
->find($VID);
return $rows;
}
}