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; }
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); } }