/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Items::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'map_address_lat' => $this->map_address_lat, 'map_address_lng' => $this->map_address_lng]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'map_address', $this->map_address]); return $dataProvider; }
/** * Finds the Items model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Items the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Items::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }