Пример #1
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     $attributeLabels = parent::attributeLabels();
     $attributeLabels['cms_news_i18n_title'] = Yii::t('kalibao', 'model:title');
     $attributeLabels['cms_news_group_i18n_title'] = Yii::t('kalibao', 'cms_news:cms_news_group_id');
     $attributeLabels['cms_news_i18n_content'] = Yii::t('kalibao', 'cms_news_i18n:content');
     return $attributeLabels;
 }
Пример #2
0
 /**
  *
  * @return string
  */
 public function actionIndex()
 {
     // page size
     $pageSize = 2;
     // main query
     $query = CmsNews::find()->innerJoinWith(['cmsNewsI18ns' => function ($query) {
         $query->where(['i18n_id' => Yii::$app->language]);
     }])->where(['cms_news_group_id' => 2, 'activated' => 1]);
     // count query
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => $pageSize, 'defaultPageSize' => $pageSize]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->orderBy(['published_at' => SORT_DESC])->all();
     return $this->render($this->renderView, ['models' => $models, 'pages' => $pages]);
 }
Пример #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCmsNews()
 {
     return $this->hasOne(CmsNews::className(), ['id' => 'cms_news_id']);
 }
Пример #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCmsNews()
 {
     return $this->hasMany(CmsNews::className(), ['cms_news_group_id' => 'id']);
 }