Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = news::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, 'created_date' => $this->created_date, 'updated_date' => $this->updated_date]);
     $query->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'title_en', $this->title_en])->andFilterWhere(['like', 'title_ru', $this->title_ru])->andFilterWhere(['like', 'title_am', $this->title_am])->andFilterWhere(['like', 'description_en', $this->description_en])->andFilterWhere(['like', 'description_ru', $this->description_ru])->andFilterWhere(['like', 'description_am', $this->description_am])->andFilterWhere(['like', 'images', $this->images])->andFilterWhere(['like', 'attachment', $this->attachment]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Finds the news model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return news the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = news::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }