public function actionView($alias, $lang = null) { $model = ServicesRecord::find()->where(['alias' => $alias])->lang($lang)->one(); \Yii::$app->params['currentModel'] = $model; if (!$model) { throw new HttpException(404); } $models = ServicesRecord::find()->lang($lang)->all(); return $this->render('view', ['model' => $model, 'models' => $models]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = ServicesRecord::find()->lang()->position(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'position' => $this->position]); $query->andFilterWhere(['like', 'lang', $this->lang])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'metaKeywords', $this->metaKeywords])->andFilterWhere(['like', 'metaDescription', $this->metaDescription]); return $dataProvider; }
public function getService() { return $this->hasOne(ServicesRecord::className(), ['id' => 'serviceId', 'lang' => 'lang']); }