/** * @inheritdoc */ public function init() { $this->searchModel = Yii::createObject(['class' => $this->modelClass]); if (!$this->searchModel instanceof UrlModel) { throw new InvalidConfigException('$rule->modelClass reference must be an instance of ' . UrlModel::className()); } if (is_null(UrlCategory::findOne($this->category))) { throw new InvalidConfigException('Category "' . $this->category . '" does not exists in ' . UrlCategory::tableName() . ' table'); } }
/** * @return \yii\db\ActiveQuery */ public function getCategory() { return $this->hasOne(UrlCategory::className(), ['id' => 'category_id']); }