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.
53 lines
1.4 KiB
PHP
53 lines
1.4 KiB
PHP
<?php
|
|
namespace App\Models\Specimen;
|
|
|
|
use App\Models\BaseModel;
|
|
use App\Libraries\ValueSet;
|
|
|
|
class ContainerDefModel extends BaseModel {
|
|
protected $table = 'containerdef';
|
|
protected $primaryKey = 'ConDefID';
|
|
protected $allowedFields = ['SiteID', 'ConCode', 'ConName', 'ConDesc', 'Additive', 'ConClass', 'Color', 'CreateDate', 'EndDate'];
|
|
|
|
protected $useTimestamps = true;
|
|
protected $createdField = 'CreateDate';
|
|
protected $updatedField = '';
|
|
protected $useSoftDeletes = true;
|
|
protected $deletedField = 'EndDate';
|
|
|
|
|
|
public function getContainers($filter = []) {
|
|
$builder = $this->select('containerdef.*');
|
|
|
|
if (!empty($filter['ConCode'])) {
|
|
$builder->like('containerdef.ConCode', $filter['ConCode'], 'both');
|
|
}
|
|
if (!empty($filter['ConName'])) {
|
|
$builder->like('containerdef.ConName', $filter['ConName'], 'both');
|
|
}
|
|
|
|
$rows = $builder->findAll();
|
|
$rows = ValueSet::transformLabels($rows, [
|
|
'Color' => 'container_cap_color',
|
|
'ConClass' => 'container_class',
|
|
'Additive' => 'additive',
|
|
]);
|
|
return $rows;
|
|
}
|
|
|
|
public function getContainer($ConDefID) {
|
|
$row = $this->select('containerdef.*')
|
|
->where('ConDefID', $ConDefID)->first();
|
|
|
|
if (!$row) return null;
|
|
|
|
$row = ValueSet::transformLabels([$row], [
|
|
'Color' => 'container_cap_color',
|
|
'ConClass' => 'container_class',
|
|
'Additive' => 'additive',
|
|
])[0];
|
|
|
|
return $row;
|
|
}
|
|
}
|