コード例 #1
0
ファイル: RubricSearch.php プロジェクト: tpoxa/cmars
 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;
 }
コード例 #2
0
ファイル: RubricsController.php プロジェクト: tpoxa/cmars
 protected function findModel($id)
 {
     if (is_array($id)) {
         $model = Rubric::find()->where(['id' => $id])->all();
     } else {
         $model = Rubric::findOne($id);
     }
     if ($model !== null) {
         return $model;
     } else {
         throw new HttpException(404);
     }
 }