- Add BaseModel with automatic camel/snake case conversion - Add stringcase_helper with camel_to_snake(), snake_to_camel() functions - Update all models to extend BaseModel for consistent data handling - Update API controllers with standardized JSON response format - Remove legacy v1 PHP application directory - Consolidate documentation into AGENTS.md, delete VIEWS_RULES.md
33 lines
1023 B
PHP
33 lines
1023 B
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Models\BaseModel;
|
|
|
|
class ControlTestModel extends BaseModel
|
|
{
|
|
protected $table = 'control_tests';
|
|
protected $primaryKey = 'control_test_id';
|
|
protected $useAutoIncrement = true;
|
|
protected $returnType = 'array';
|
|
protected $useSoftDeletes = true;
|
|
protected $useTimestamps = true;
|
|
protected $allowedFields = ['control_ref_id', 'test_ref_id', 'mean', 'sd'];
|
|
|
|
public function getByControl($controlId)
|
|
{
|
|
$builder = $this->db->table('control_tests ct');
|
|
$builder->select('ct.*, t.name as test_name, t.unit');
|
|
$builder->join('dict_tests t', 't.test_id = ct.test_ref_id');
|
|
$builder->where('ct.control_ref_id', $controlId);
|
|
return $builder->get()->getResultArray();
|
|
}
|
|
|
|
public function getByControlAndTest($controlId, $testId)
|
|
{
|
|
return $this->where('control_ref_id', $controlId)
|
|
->where('test_ref_id', $testId)
|
|
->first();
|
|
}
|
|
}
|