Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Projects::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, 'active' => $this->active]);
     $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
 public function actionServices()
 {
     $pages = new Pagination(['totalCount' => Projects::find()->count(), 'forcePageParam' => false, 'pageSizeParam' => false, 'defaultPageSize' => 1]);
     $projects = Projects::find()->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('services', ['projects' => $projects, 'pages' => $pages]);
 }