Exemplo n.º 1
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategories()
 {
     return $this->hasMany(CategoryRecord::className(), ['language_id' => 'id']);
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     return parent::find()->andWhere(['category_type' => self::TYPE_CATEGORY]);
 }
Exemplo n.º 3
0
 /**
  * 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;
 }