public function actionIndex() { $countList = TrainLand::getCountList(); $query = TrainLand::find(); $countQuery = clone $query; $pages = new Pagination(['totalCount' => $countQuery->count()]); $models = $query->offset($pages->offset)->limit($pages->limit)->all(); $count = count($countList); $data = ['count' => $count, 'models' => $models, 'pages' => $pages]; return $this->render('index', ['data' => $data]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = TrainLand::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, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'contacts', $this->contacts])->andFilterWhere(['like', 'contact_phone', $this->contact_phone])->andFilterWhere(['like', 'site_type', $this->site_type])->andFilterWhere(['like', 'bus', $this->bus])->andFilterWhere(['like', 'site', $this->site])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_use', $this->update_user]); return $dataProvider; }