tinyqc/app/Models/DictTestModel.php

30 lines
855 B
PHP
Raw Normal View History

<?php
namespace App\Models;
use CodeIgniter\Model;
class DictTestModel extends Model
{
protected $table = 'dict_tests';
protected $primaryKey = 'test_id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $allowedFields = ['test_id', 'dept_ref_id', 'name', 'unit', 'method', 'cva', 'ba', 'tea'];
protected $useTimestamps = false;
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();
}
}