Пример #1
0
 public function down()
 {
     $this->dropTable(Rubric::tableName());
     $this->dropTable(RubricTranslate::tableName());
     $this->dropTable(Post::tableName());
     $this->dropTable(PostTranslate::tableName());
 }
Пример #2
0
 public static function getRubricsForSelect($app_id = 0)
 {
     $sections = [];
     $sql = "SELECT s.id, st.title\n                FROM " . Rubric::tableName() . " as s\n                LEFT JOIN " . RubricTranslate::tableName() . " as st\n                   ON s.id = st.rubric_id\n                WHERE st.language = :lang and s.app_id = :app_id\n                    \n        ";
     $models = RubricTranslate::findBySql($sql, [':lang' => Yii::$app->language, ':app_id' => $app_id])->all();
     foreach ($models as $model) {
         $sections[$model->id] = $model->title;
     }
     return $sections;
 }
Пример #3
0
 public function search($params)
 {
     $query = Rubric::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => $this->recordsPerPage]]);
     $query->andWhere(['app_id' => \Yii::$app->getModule('cms')->app_id]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->leftJoin(RubricTranslate::tableName() . ' as tr ', '' . Rubric::tableName() . '.id = tr.rubric_id AND tr.language = \'' . Yii::$app->language . '\'');
     $query->andWhere(['like', 'tr.title', $this->title]);
     $query->andWhere(['like', Rubric::tableName() . '.name', $this->name]);
     return $dataProvider;
 }