/** * @return \yii\db\ActiveQuery */ public function getCategories() { return $this->hasMany(CategoryRecord::className(), ['language_id' => 'id']); }
/** * @inheritdoc */ public static function find() { return parent::find()->andWhere(['category_type' => self::TYPE_CATEGORY]); }
/** * Returns content list options for dropdown * @return array */ public function getContentListOptions() { $session = Yii::$app->session; if (!$session['language_id']) { $session['language_id'] = LanguageRecord::getMainLanguageId(); } $items = []; switch ($this->content_type) { case MenuItemRecord::CONTENT_PAGE: $items = ArrayHelper::map(ContentRecord::find()->where(['language_id' => $session['language_id'], 'content_type' => ContentRecord::TYPE_PAGE])->activeStatus()->orderBy('updated_at DESC')->all(), 'id', 'title'); break; case MenuItemRecord::CONTENT_CATEGORY: $items = ArrayHelper::map(CategoryRecord::find()->where(['language_id' => $session['language_id'], 'category_type' => CategoryRecord::TYPE_CATEGORY])->activeStatus()->orderBy('updated_at DESC')->all(), 'id', 'title'); break; default: break; } return $items; }