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(); } }