Exemplo n.º 1
0
 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]);
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
0
 public function getService()
 {
     return $this->hasOne(ServicesRecord::className(), ['id' => 'serviceId', 'lang' => 'lang']);
 }