clqms-be/app/Models/Organization/WorkstationModel.php
root 2bcdf09b55 chore: repo-wide normalization + rules test coverage
Normalize formatting/line endings across configs, controllers, models, tests, and OpenAPI specs.

Update rule expression/rule engine implementation and remove obsolete RuleAction controller/model.

Add unit tests for rule expression syntax and multi-action behavior, and include docs updates.
2026-03-16 07:24:50 +07:00

50 lines
1.8 KiB
PHP

<?php
namespace App\Models\Organization;
use App\Models\BaseModel;
use App\Libraries\ValueSet;
class WorkstationModel extends BaseModel {
protected $table = 'workstation';
protected $primaryKey = 'WorkstationID';
protected $allowedFields = ['DepartmentID', 'WorkstationCode', 'WorkstationName', 'Type', 'LinkTo', 'Enable',
'EquipmentID', 'CreateDate', 'EndDate'];
protected $useTimestamps = true;
protected $createdField = 'CreateDate';
protected $updatedField = '';
protected $useSoftDeletes = true;
protected $deletedField = 'EndDate';
public function getWorkstations($filter = []) {
$this->select('workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName')
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left');
if (!empty($filter['WorkstationCode'])) {
$this->like('workstation.WorkstationCode', $filter['WorkstationCode'], 'both');
}
if (!empty($filter['WorkstationName'])) {
$this->like('workstation.WorkstationName', $filter['WorkstationName'], 'both');
}
$rows = $this->findAll();
return $rows;
}
public function getWorkstation($WorkstationID) {
$row = $this->select("workstation.*, department.DepartmentName, wst1.WorkstationName as LinkToName")
->join('workstation wst1', 'workstation.LinkTo=wst1.WorkstationID', 'left')
->join('department', 'department.DepartmentID=workstation.DepartmentID', 'left')
->where('workstation.WorkstationID', $WorkstationID)
->first();
if (!$row) return null;
$row = ValueSet::transformLabels([$row], [
'Type' => 'ws_type',
'Enable' => 'enable_disable',
])[0];
return $row;
}
}