clqms-be/app/Models/Infrastructure/EquipmentListModel.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

66 lines
2.3 KiB
PHP
Executable File

<?php
namespace App\Models\Infrastructure;
use App\Models\BaseModel;
class EquipmentListModel extends BaseModel {
protected $table = 'equipmentlist';
protected $primaryKey = 'EID';
protected $allowedFields = [
'IEID',
'DepartmentID',
'InstrumentID',
'InstrumentName',
'WorkstationID',
'isEnable',
'EquipmentRole',
'CreateDate',
'EndDate'
];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getEquipmentLists($filter = []) {
$builder = $this->builder();
$builder->select('equipmentlist.*, department.DepartmentName, workstation.WorkstationName')
->join('department', 'department.DepartmentID = equipmentlist.DepartmentID', 'left')
->join('workstation', 'workstation.WorkstationID = equipmentlist.WorkstationID', 'left');
if (!empty($filter['IEID'])) {
$builder->like('equipmentlist.IEID', $filter['IEID'], 'both');
}
if (!empty($filter['InstrumentName'])) {
$builder->like('equipmentlist.InstrumentName', $filter['InstrumentName'], 'both');
}
if (!empty($filter['DepartmentID'])) {
$builder->where('equipmentlist.DepartmentID', $filter['DepartmentID']);
}
if (!empty($filter['WorkstationID'])) {
$builder->where('equipmentlist.WorkstationID', $filter['WorkstationID']);
}
if (isset($filter['isEnable'])) {
$builder->where('equipmentlist.isEnable', $filter['isEnable']);
}
$rows = $builder->get()->getResultArray();
return $rows;
}
public function getEquipmentList($EID) {
$builder = $this->builder();
$row = $builder->select('equipmentlist.*, department.DepartmentName, workstation.WorkstationName')
->join('department', 'department.DepartmentID = equipmentlist.DepartmentID', 'left')
->join('workstation', 'workstation.WorkstationID = equipmentlist.WorkstationID', 'left')
->where('equipmentlist.EID', $EID)
->get()
->getRowArray();
return $row;
}
}