コード例 #1
0
ファイル: LanguageRecord.php プロジェクト: czechcamus/dasport
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategories()
 {
     return $this->hasMany(CategoryRecord::className(), ['language_id' => 'id']);
 }
コード例 #2
0
ファイル: Category.php プロジェクト: czechcamus/dasport
 /**
  * @inheritdoc
  */
 public static function find()
 {
     return parent::find()->andWhere(['category_type' => self::TYPE_CATEGORY]);
 }
コード例 #3
0
ファイル: MenuItemForm.php プロジェクト: czechcamus/dasport
 /**
  * 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;
 }