/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Shop::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'logo_img', $this->logo_img])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'working_time', $this->working_time])->andFilterWhere(['like', 'delivery', $this->delivery])->andFilterWhere(['like', 'phone_1', $this->phone_1])->andFilterWhere(['like', 'phone_2', $this->phone_2])->andFilterWhere(['like', 'phone_3', $this->phone_3])->andFilterWhere(['like', 'phone_4', $this->phone_4])->andFilterWhere(['like', 'phone_5', $this->phone_5])->andFilterWhere(['like', 'phone_6', $this->phone_6])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'lat', $this->lat])->andFilterWhere(['like', 'lng', $this->lng]); return $dataProvider; }
public function actionIndex() { $query = Shop::find(); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count()]); $sort = new Sort(['attributes' => ['id']]); $models = $query->orderBy($sort->orders)->offset($pages->offset)->limit($pages->limit)->all(); # ---------- $model = new Shop(); $model->attributes = Yii::$app->request->post('searchForm'); $dataProvider = new ActiveDataProvider(['query' => Shop::find(), 'pagination' => ['pageSize' => 2]]); return $this->render('index', ['models' => $models, 'pages' => $pages, 'sort' => $sort, 'dataProvider' => $dataProvider, 'model' => $model]); }
public function actionList() { $this->view->title = \Yii::t('wallet', 'Shops'); $shops = Shop::find()->all(); return $this->render('list', ['shops' => $shops]); }