public static function itemAilas($key, $code = NULL) { $items = array('SectRecordList' => ArrayHelper::map(Sect::find()->all(), 'Code', 'Name'), 'riskEffList' => ArrayHelper::map(RiskEff::find()->all(), 'Code', 'Name'), 'riskList' => ArrayHelper::map(Risk2::find()->all(), 'Code', 'Name')); //return array_key_exists($key, $items) ? $items[$key] : []; if (isset($code)) { return isset($items[$key][$code]) ? $items[$key][$code] : false; } else { return isset($items[$key]) ? $items[$key] : false; } }
public function getRisk($id) { $data = Risk2::find()->where(['Code' => $id])->asArray()->one(); return $data['Name']; }