Exemplo n.º 1
0
 /**
  * Prepares the data provider that should return the requested collection of the models.
  * @return ActiveDataProvider
  */
 protected function prepareDataProvider()
 {
     if ($this->prepareDataProvider !== null) {
         return call_user_func($this->prepareDataProvider, $this);
     }
     /**
      * @var \yii\db\BaseActiveRecord $modelClass
      */
     $modelClass = $this->modelClass;
     $searchClass = new VenueSearch();
     $query = $modelClass::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     // $query->andFilterWhere(['NOT',['status' => '0']]);
     $query->andWhere("not ((`state`=" . AppActiveRecord::STATUS_DRAFT . ") AND (`createdBy`!=" . \yii::$app->user->id . "))");
     if (!($searchClass->load(Yii::$app->request->queryParams, '') && $searchClass->validate())) {
         $query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]);
         $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]);
         return $dataProvider;
     }
     //$query->orderBy(['updatedOn' => SORT_DESC]);
     //*/
     $query->andFilterWhere(['Id' => $searchClass->Id, 'categoryId' => $searchClass->categoryId, 'cityId' => $searchClass->cityId, 'zoneId' => $searchClass->zoneId, 'localityId' => $searchClass->localityId, 'gpsLat' => $searchClass->gpsLat, 'gpsLong' => $searchClass->gpsLong, 'venueType' => $searchClass->venueType, 'capacity' => $searchClass->capacity, 'startTime' => $searchClass->startTime, 'endTime' => $searchClass->endTime, 'IsReccomended' => $searchClass->IsReccomended, 'status' => $searchClass->status, 'flag' => $searchClass->flag, 'createdOn' => $searchClass->createdOn, 'createdBy' => $searchClass->createdBy, 'updatedOn' => $searchClass->updatedOn, 'updatedBy' => $searchClass->updatedBy, 'csvUpload' => $searchClass->csvUpload, 'entityType' => $searchClass->entityType]);
     //*/
     if ($searchClass->state !== null) {
         if ($searchClass->state == AppActiveRecord::STATUS_DRAFT) {
             $query->andFilterWhere(['state' => $searchClass->state, 'createdBy' => \yii::$app->user->id]);
         } else {
             $query->andFilterWhere(['state' => $searchClass->state]);
         }
     } else {
         $query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]);
     }
     $query->andFilterWhere(['like', 'name', $searchClass->name])->andFilterWhere(['like', 'address', $searchClass->address])->andFilterWhere(['like', 'landmark', $searchClass->landmark])->andFilterWhere(['like', 'tollfree', $searchClass->tollfree])->andFilterWhere(['like', 'facility', $searchClass->facility])->andFilterWhere(['like', 'description', $searchClass->description])->andFilterWhere(['like', 'contactName', $searchClass->contactName])->andFilterWhere(['like', 'email', $searchClass->email])->andFilterWhere(['like', 'url', $searchClass->url])->andFilterWhere(['like', 'facebookUrl', $searchClass->facebookUrl])->andFilterWhere(['like', 'seatType', $searchClass->seatType])->andFilterWhere(['like', 'reservationInfo', $searchClass->reservationInfo])->andFilterWhere(['like', 'audiVsCapcity', $searchClass->audiVsCapcity])->andFilterWhere(['like', 'ip', $searchClass->ip])->andFilterWhere(['like', 'oldGuid', $searchClass->oldGuid])->andFilterWhere(['like', 'guid', $searchClass->guid])->andFilterWhere(['like', 'csvRemarks', $searchClass->csvRemarks])->andFilterWhere(['like', 'brand', $searchClass->brand])->andFilterWhere(['like', 'mall', $searchClass->mall]);
     return $dataProvider;
 }