Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 public function getInfotext()
 {
     return $this->hasMany(\app\modules\seotools\models\base\Infotext::className(), array('meta_id' => 'id_meta'));
 }
Esempio n. 3
0
 /**
  * Finds the Infotext1 model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Infotext1 the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Infotext::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 4
0
 /**
  *  Находит и заменяет текст 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;
 }