/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Infotext::find(); $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, 'meta_id' => $this->meta_id, 'city_id' => $this->city_id]); $query->andFilterWhere(['like', 'infotext_before', $this->infotext_before])->andFilterWhere(['like', 'infotext_after', $this->infotext_after]); return $dataProvider; }
/** * Находит и заменяет текст before и after для города, если есть * @param $aMeta * @return array */ public function replaceInfotext($aMeta) { $infotext = \app\modules\seotools\models\base\Infotext::find()->select('infotext_before, infotext_after')->where(['meta_id' => $aMeta['id_meta'], 'city_id' => $this->city])->asArray()->one(); if (!empty($infotext)) { $aMeta = array_merge($aMeta, $infotext); } return $aMeta; }