/** * @return \yii\db\ActiveQuery */ public function getSpecType() { return $this->hasOne(SpecialistType::className(), ['id' => 'spec_type_id']); }
/** * Извлекаем список профессий специалистов */ public function getSpecType() { $query = $this->hasMany(SpecialistType::className(), ['id' => 'spec_type_id'])->viaTable('tbl_specialist_has_type', ['spec_id' => 'specialist_id']); if (is_numeric(Yii::$app->request->get('spec_type'))) { $query->where(['tbl_specialist_type.id' => (int) Yii::$app->request->get('spec_type')]); } return $query; }
/** * @return \yii\db\ActiveQuery */ public function getSpecTypes() { return $this->hasMany(SpecialistType::className(), ['id' => 'spec_type_id'])->viaTable('tbl_specialist_has_type', ['spec_id' => 'id']); }