tinyqc/app/Models/TestModel.php
mahdahar 18b85815ce refactor: standardize codebase with BaseModel and new conventions
- 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
2026-01-15 10:44:09 +07:00

30 lines
845 B
PHP

<?php
namespace App\Models;
use App\Models\BaseModel;
class TestModel extends BaseModel
{
protected $table = 'dict_tests';
protected $primaryKey = 'test_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = true;
protected $useTimestamps = true;
protected $allowedFields = ['dept_ref_id', 'name', 'unit', 'method', 'cva', 'ba', 'tea'];
public function getByDept($deptId)
{
return $this->where('dept_ref_id', $deptId)->findAll();
}
public function getWithDept()
{
$builder = $this->db->table('dict_tests t');
$builder->select('t.*, d.name as dept_name');
$builder->join('dict_depts d', 'd.dept_id = t.dept_ref_id', 'left');
return $builder->get()->getResultArray();
}
}