ActiveDataProvider provides data by performing DB queries using [[query]]. The following is an example of using ActiveDataProvider to provide ActiveRecord instances: php $provider = new ActiveDataProvider([ 'query' => Post::find(), 'pagination' => [ 'pageSize' => 20, ], ]); get the posts in the current page $posts = $provider->getModels(); And the following example shows how to use ActiveDataProvider without ActiveRecord: php $query = new Query(); $provider = new ActiveDataProvider([ 'query' => $query->from('post'), 'pagination' => [ 'pageSize' => 20, ], ]); get the posts in the current page $posts = $provider->getModels(); For more details and usage information on ActiveDataProvider, see the guide article on data providers.
Since: 2.0
Author: Qiang Xue (qiang.xue@gmail.com)
Inheritance: extends BaseDataProvider
Beispiel #1
0
 public function existUser($post)
 {
     $model = new $this->modelClass();
     $query = $model::find()->orFilterWhere(['login' => $post['login']])->orFilterWhere(['email' => $post['email']]);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 5]]);
     return $dataProvider->getCount() === 0 ? false : true;
 }
 /**
  * Список учителей, с которыми занимаются только ученики, родившиеся в апреле.
  * @return mixed
  */
 public function actionApril()
 {
     $title = 'Список учителей, с которыми занимаются только ученики, родившиеся в апреле';
     $dataProvider = new ActiveDataProvider(['query' => Teacher::teachsOnlyAprilBornStudents()]);
     $dataProvider->setSort(['defaultOrder' => ['name' => SORT_ASC], 'attributes' => ['name', 'gender', 'phone', 'students_count' => ['asc' => ['stud_cnt' => SORT_ASC], 'desc' => ['stud_cnt' => SORT_DESC]]]]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'title' => $title]);
 }
Beispiel #3
0
 /** 
  * Creates data provider instance with search query applied 
  * 
  * @param array $params 
  * 
  * @return ActiveDataProvider 
  */
 public function search($params)
 {
     $query = Lesson::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'groupName' => ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC], 'label' => 'groupName'], 'disciplineName' => ['asc' => ['discipline.name' => SORT_ASC], 'desc' => ['discipline.name' => SORT_DESC], 'label' => 'disciplineName'], 'teacherFullname' => ['asc' => ['user.last_name' => SORT_ASC, 'user.first_name' => SORT_ASC, 'user.middle_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC, 'user.first_name' => SORT_DESC, 'user.middle_name' => SORT_DESC], 'label' => 'teacherFullname'], 'lessonTypeName' => ['asc' => ['lesson_type.name' => SORT_ASC], 'desc' => ['lesson_type.name' => SORT_DESC], 'label' => 'lessonTypeName'], 'week', 'day', 'time', 'auditory']]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'ghd_id' => $this->ghd_id, 'lesson_type_id' => $this->lesson_type_id, 'week' => $this->week, 'day' => $this->day, 'time' => $this->time, 'date' => $this->date]);
     $query->andFilterWhere(['like', 'auditory', $this->auditory]);
     $query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.group' => function ($q) {
         $q->where('group.name LIKE "%' . $this->groupName . '%" ');
     }]);
     $query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.discipline' => function ($q) {
         $q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
     }]);
     $query->joinWith('teacherHasDiscipline')->joinWith('teacherHasDiscipline.teacher')->joinWith(['teacherHasDiscipline.teacher.user' => function ($q) {
         $q->where('user.first_name LIKE "%' . $this->teacherFullname . '%" ' . 'OR user.last_name LIKE "%' . $this->teacherFullname . '%"' . 'OR user.middle_name LIKE "%' . $this->teacherFullname . '%"');
     }]);
     $query->joinWith(['lessonType' => function ($q) {
         $q->where('lesson_type.name LIKE "%' . $this->lessonTypeName . '%" ');
     }]);
     return $dataProvider;
 }
Beispiel #4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Comment::find()->select('comment.*, video.title, user.username')->innerJoin('video', '`video`.`id` = `comment`.`video_id`')->innerJoin('user', '`user`.`id` = `comment`.`user_id`');
     // echo $query->createCommand()->sql;exit;
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->params['pageSize']]]);
     /**
      * Setup your sorting attributes
      * Note: This is setup before the $this->load($params) 
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['id', 'text' => ['asc' => ['comment.text' => SORT_ASC], 'desc' => ['comment.text' => SORT_DESC]], 'videoTitle' => ['asc' => ['video.title' => SORT_ASC], 'desc' => ['video.title' => SORT_DESC]], 'username' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC]], 'created_at' => ['asc' => ['comment.created_at' => SORT_ASC], 'desc' => ['comment.created_at' => SORT_DESC]]]]);
     $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;
     }
     /* ---------------------------------------------------------------------/
      * Filter
      * --------------------------------------------------------------------- */
     $query->andFilterWhere(['comment.id' => $this->id, 'comment.video_id' => $this->video_id, 'comment.user_id' => $this->user_id, 'comment.created_at' => $this->created_at, 'comment.modified_at' => $this->modified_at]);
     $query->andFilterWhere(['like', 'text', $this->text]);
     /**
      * for related column
      */
     $query->andFilterWhere(['like', 'video.title', $this->videoTitle]);
     $query->andFilterWhere(['like', 'user.username', $this->username]);
     return $dataProvider;
 }
Beispiel #5
0
 public function search($params)
 {
     $query = group::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['parentId' => SORT_ASC, 'name' => SORT_ASC]]);
     $query->andFilterWhere([group::tableName() . '.status' => '1']);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['parent']);
         return $dataProvider;
     }
     /*$query->andFilterWhere([
           'Id' => $this->Id,
           'createdon' => $this->createdon,
       ]);//*/
     $query->andFilterWhere(['like', group::tableName() . '.name', $this->name]);
     //->andFilterWhere(['like', 'parentId', $this->ParentGroup])
     //->andFilterWhere(['like', 'status', $this->status]);
     if ($this->parentGroup != '' && strtolower($this->parentGroup) != 'root') {
         $query->joinWith(['parent' => function ($q) {
             $q->where('parent.name LIKE "%' . $this->parentGroup . '%" ');
         }]);
     } else {
         if (strtolower($this->parentGroup) == 'root') {
             $query->andFilterWhere([group::tableName() . '.parentId' => 0]);
         }
     }
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $newquery = null)
 {
     $query = GroupHasDiscipline::find();
     if ($newquery) {
         $query = $newquery;
     }
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'semester_number', 'semesterNumber' => ['asc' => ['group_semesters.semester_number' => SORT_ASC], 'desc' => ['group_semesters.semester_number' => SORT_DESC]], 'groupName' => ['asc' => ['group.name' => SORT_ASC], 'desc' => ['group.name' => SORT_DESC]], 'disciplineName' => ['asc' => ['discipline.name' => SORT_ASC], 'desc' => ['discipline.name' => SORT_DESC]]]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'discipline_id' => $this->discipline_id, 'group_id' => $this->group_id, 'group_has_discipline.semester_number' => $this->semester_number]);
     $query->joinWith(['semester' => function ($q) {
         $q->where('group_semesters.semester_number LIKE "%' . $this->semesterNumber . '%" ');
     }]);
     $query->joinWith(['group' => function ($q) {
         $q->where('group.name LIKE "%' . $this->groupName . '%" ');
     }]);
     $query->joinWith(['discipline' => function ($q) {
         $q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
     }]);
     return $dataProvider;
 }
Beispiel #7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Work::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'studentFullname' => ['asc' => ['user.last_name' => SORT_ASC], 'desc' => ['user.last_name' => SORT_DESC], 'label' => 'studentFullname'], 'groupName' => ['asc' => ['student.group.name' => SORT_ASC], 'desc' => ['student.group.name' => SORT_DESC], 'label' => 'groupName'], 'disciplineName' => ['asc' => ['groupHasDiscipline.discipline.name' => SORT_ASC], 'desc' => ['groupHasDiscipline.discipline.name' => SORT_DESC]]]]);
     $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, 'work_type_id' => $this->work_type_id, 'name' => $this->name, 'student_id' => $this->student_id, 'teacher_id' => $this->teacher_id, 'date' => $this->date, 'approve_status' => $this->approve_status]);
     $query->joinWith('student')->joinWith(['student.user' => function ($q) {
         $q->where('user.first_name LIKE "%' . $this->studentFullname . '%" ' . 'OR user.last_name LIKE "%' . $this->studentFullname . '%"' . 'OR user.middle_name LIKE "%' . $this->studentFullname . '%"');
     }]);
     $query->joinWith('student')->joinWith(['student.group' => function ($q) {
         $q->where('group.name LIKE "%' . $this->groupName . '%" ');
     }]);
     if ($this->work_type_id == Work::TYPE_TERM) {
         $query->joinWith('groupHasDiscipline')->joinWith(['groupHasDiscipline.discipline' => function ($q) {
             $q->where('discipline.name LIKE "%' . $this->disciplineName . '%" ');
         }]);
     }
     return $dataProvider;
 }
Beispiel #8
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /**
      * Setup your sorting attributes
      * Note: This is setup before the $this->load($params)
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['id', 'userIdLink' => ['asc' => ['user.id' => SORT_ASC], 'desc' => ['user.id' => SORT_DESC], 'label' => 'ID'], 'userLink' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC], 'label' => 'User'], 'perfilLink' => ['asc' => ['perfil.id' => SORT_ASC], 'desc' => ['perfil.id' => SORT_DESC], 'label' => 'Perfil'], 'rolNombre' => ['asc' => ['rol.rol_name' => SORT_ASC], 'desc' => ['rol.rol_name' => SORT_DESC], 'label' => 'Rol'], 'estadoNombre' => ['asc' => ['estado.estado_nombre' => SORT_ASC], 'desc' => ['estado.estado_nombre' => SORT_DESC], 'label' => 'Estado'], 'created_at' => ['asc' => ['created_at' => SORT_ASC], 'desc' => ['created_at' => SORT_DESC], 'label' => 'Created At'], 'email' => ['asc' => ['email' => SORT_ASC], 'desc' => ['email' => SORT_DESC], 'label' => 'Email']]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['rol'])->joinWith(['estado'])->joinWith(['perfil']);
         return $dataProvider;
     }
     $this->addSearchParameter($query, 'id');
     $this->addSearchParameter($query, 'username', true);
     $this->addSearchParameter($query, 'email', true);
     $this->addSearchParameter($query, 'rol_id');
     $this->addSearchParameter($query, 'estado_id');
     $this->addSearchParameter($query, 'created_at');
     $this->addSearchParameter($query, 'updated_at');
     // filter by role
     $query->joinWith(['rol' => function ($q) {
         $q->andFilterWhere(['=', 'rol.rol_nombre', $this->rolNombre]);
     }])->joinWith(['estado' => function ($q) {
         $q->andFilterWhere(['=', 'estado.estado_nombre', $this->estadoNombre]);
     }])->joinWith(['perfil' => function ($q) {
         $q->andFilterWhere(['=', 'perfil.id', $this->perfilId]);
     }]);
     return $dataProvider;
 }
 /**
  * @param array $params Search conditions.
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $translateLanguage = Yii::$app->request->get('language_id', Yii::$app->sourceLanguage);
     $sourceLanguage = $this->_getSourceLanguage();
     $query = LanguageSource::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'category', 'message', 'translation' => ['asc' => ['lt.translation' => SORT_ASC], 'desc' => ['lt.translation' => SORT_DESC], 'label' => Yii::t('language', 'Translation')]]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['languageTranslate' => function ($query) use($translateLanguage) {
             $query->from(['lt' => LanguageTranslate::tableName()])->onCondition(['lt.language' => $translateLanguage]);
         }]);
         $query->joinWith(['languageTranslateByLanguage' => function ($query) use($sourceLanguage) {
             $query->from(['ts' => LanguageTranslate::tableName()])->onCondition(['ts.language' => $sourceLanguage]);
         }]);
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'category' => $this->category]);
     $query->andFilterWhere(['or', $this->createLikeExpression('message', $this->message), $this->createLikeExpression('ts.translation', $this->message)]);
     $query->joinWith(['languageTranslate' => function ($query) use($translateLanguage) {
         $query->from(['lt' => LanguageTranslate::tableName()])->onCondition(['lt.language' => $translateLanguage])->andFilterWhere($this->createLikeExpression('lt.translation', $this->translation));
     }]);
     $query->joinWith(['languageTranslateByLanguage' => function ($query) use($sourceLanguage) {
         $query->from(['ts' => LanguageTranslate::tableName()])->onCondition(['ts.language' => $sourceLanguage]);
     }]);
     return $dataProvider;
 }
Beispiel #10
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find()->joinWith('profile');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $dataProvider->setSort(['attributes' => ['id', 'username', 'email', 'super_admin', 'last_login', 'profile.firstname', 'profile.lastname', 'created_at']]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     if (strtolower($this->last_login) == 'yes') {
         $query->andWhere(['not', ['last_login' => null]]);
     } else {
         if (strtolower($this->last_login) == 'no') {
             $query->andWhere(['last_login' => null]);
         }
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['super_admin' => $this->super_admin]);
     $query->andFilterWhere(['like', 'id', $this->id]);
     $query->andFilterWhere(['like', 'username', $this->username]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     $query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('profile.firstname')]);
     $query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('profile.lastname')]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     //$query = REFERRALGIVEN::find();
     $query = REFERRALGIVEN::find()->joinWith(['rEFERRAL']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /**
      * Setup your sorting attributes
      * Note: This is setup before the $this->load($params) 
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['GIVEN_ID', 'MEMBER_ID', 'referralName' => ['asc' => ['REFERRAL.REFERRAL_NAME' => SORT_ASC], 'desc' => ['REFERRAL.REFERRAL_NAME' => SORT_DESC], 'label' => 'Referral Name'], 'MEETING_ID']]);
     if (!($this->load($params) && $this->validate())) {
         //Brad
         //$query->joinWith(['rEFERRAL']);
         return $dataProvider;
     }
     $query->andFilterWhere(['GIVEN_ID' => $this->GIVEN_ID, 'MEMBER_ID' => $this->MEMBER_ID, 'REFERRAL_ID' => $this->REFERRAL_ID, 'MEETING_ID' => $this->MEETING_ID]);
     $query->andFilterWhere(['like', 'GIVEN_YOUR_CARD', $this->GIVEN_YOUR_CARD])->andFilterWhere(['like', 'TOLD_THEM_YOU_WOULD_CALL', $this->TOLD_THEM_YOU_WOULD_CALL])->andFilterWhere(['like', 'COMMENTS', $this->COMMENTS]);
     // filter by Referral name - Brad
     //        $query->joinWith(['rEFERRAL'=>function ($q) {
     //            $q->where('rEFERRAL.REFERRAL_NAME LIKE "%' .
     //                $this->referralName . '%"');
     //        }]);
     return $dataProvider;
 }
Beispiel #12
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find()->joinWith('profile');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 50]]);
     $dataProvider->setSort(['attributes' => ['id', 'username', 'email', 'super_admin', 'last_login', 'profile.firstname', 'profile.lastname', 'created_at']]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['super_admin' => $this->super_admin]);
     $query->andFilterWhere(['like', 'id', $this->id]);
     $query->andFilterWhere(['like', 'username', $this->username]);
     $query->andFilterWhere(['like', 'email', $this->email]);
     $query->andFilterWhere(['like', 'profile.firstname', $this->getAttribute('profile.firstname')]);
     $query->andFilterWhere(['like', 'profile.lastname', $this->getAttribute('profile.lastname')]);
     if ($this->getAttribute('last_login') != "") {
         try {
             $last_login = Yii::$app->formatter->asDate($this->getAttribute('last_login'), 'php:Y-m-d');
             $query->andWhere(['=', new \yii\db\Expression("DATE(last_login)"), new \yii\db\Expression("DATE(:last_login)", [':last_login' => $last_login])]);
         } catch (InvalidParamException $e) {
             // do not change the query if the date is wrong formatted
         }
     }
     return $dataProvider;
 }
Beispiel #13
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Books::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /**
      * Настройка параметров сортировки
      * Важно: должна быть выполнена раньше $this->load($params)
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['id', 'name', 'author' => ['asc' => ['lastname' => SORT_ASC, 'firstname' => SORT_ASC], 'desc' => ['lastname' => SORT_DESC, 'firstname' => SORT_DESC], 'default' => SORT_ASC], 'date', 'date_create']]);
     $query->joinWith(['authors']);
     if (!($this->load($params) && $this->validate())) {
         /**
          * Жадная загрузка данных модели Страны
          * для работы сортировки.
          */
         return $dataProvider;
     }
     $query->andFilterWhere(['books.id' => $this->id, 'author_id' => $this->author_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     // Фильтр по полному имени
     $query->andWhere('authors.firstname LIKE "%' . $this->author . '%" ' . 'OR authors.lastname LIKE "%' . $this->author . '%"');
     // Фильтр по дате
     /*
     // Если на форме нужно воодить как на плейсхолдере
     $myDateTime= DateTime::createFromFormat('d/m/Y', $this->date_begin);
     $myDateTime->format('Y-m-d');
     */
     $query->andFilterWhere(['>=', 'date', $this->date_begin]);
     $query->andFilterWhere(['<=', 'date', $this->date_end]);
     return $dataProvider;
 }
 /**
  * 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 EventSearch();
     $query = $modelClass::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]);
     $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]]);
         return $dataProvider;
     }
     if ($searchClass->state !== null) {
         if ($searchClass->state == AppActiveRecord::STATUS_DRAFT) {
             $query->andFilterWhere(['state' => $this->state, 'createdBy' => \yii::$app->user->id]);
         } else {
             $query->andFilterWhere(['state' => $searchClass->state]);
         }
     } else {
         $query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]);
     }
     $query->andFilterWhere(['Id' => $searchClass->Id, 'sourceId' => $searchClass->sourceId, 'cityId' => $searchClass->cityId, 'zoneId' => $searchClass->zoneId, 'localityId' => $searchClass->localityId, 'gpsLat' => $searchClass->gpsLat, 'gpsLong' => $searchClass->gpsLong, 'startDate' => $searchClass->startDate, 'endDate' => $searchClass->endDate, 'startTime' => $searchClass->startTime, 'endTime' => $searchClass->endTime, 'status' => $searchClass->status, 'isRecursive' => $searchClass->isRecursive, 'healthStatus' => $searchClass->healthStatus, 'createdOn' => $searchClass->createdOn, 'createdBy' => $searchClass->createdBy, 'updatedOn' => $searchClass->updatedOn, 'updatedBy' => $searchClass->updatedBy]);
     $query->andFilterWhere(['like', 'categoryId', $searchClass->categoryId])->andFilterWhere(['like', 'name', $searchClass->name])->andFilterWhere(['like', 'description', $searchClass->description])->andFilterWhere(['like', 'address', $searchClass->address])->andFilterWhere(['like', 'landmark', $searchClass->landmark])->andFilterWhere(['like', 'pincode', $searchClass->pincode])->andFilterWhere(['like', 'tollfree', $searchClass->tollfree])->andFilterWhere(['like', 'contactName', $searchClass->contactName])->andFilterWhere(['like', 'email', $searchClass->email])->andFilterWhere(['like', 'url', $searchClass->url])->andFilterWhere(['like', 'shopurl', $searchClass->shopurl])->andFilterWhere(['like', 'price', $searchClass->price])->andFilterWhere(['like', 'ip', $searchClass->ip])->andFilterWhere(['like', 'recursionData', $searchClass->recursionData])->andFilterWhere(['like', 'oldGuid', $searchClass->oldGuid])->andFilterWhere(['like', 'guid', $searchClass->guid])->andFilterWhere(['like', 'multipleTimings', $searchClass->multipleTimings])->andFilterWhere(['like', 'weekdaysChecklist', $searchClass->weekdaysChecklist]);
     /*$query->joinWith('eventMap')->andFilterWhere(['like', 'phone', $this->phone])
       ->andFilterWhere(['like', 'mobile', $this->mobile]);//*/
     return $dataProvider;
 }
 /**
  * Lists all Applyjobs models.
  * @return mixed
  */
 public function actionSearch()
 {
     $data = Yii::$app->request->post();
     $longitude = $data['longitude'];
     $latitude = $data['latitude'];
     $query = (new \yii\db\Query())->select('daters.*,users.phone,users.nickname,users.thumb,hobbies.hobby')->from('daters')->orderBy(sprintf('abs(daters.longitude - %f) + abs(daters.latitude - %f)', $longitude, $latitude))->join('INNER JOIN', 'users', 'daters.userid = users.id')->join('INNER JOIN', 'hobbies', 'daters.hobbyid = hobbies.id');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     //$this->load($params);
     //$value = 0;
     if (!empty($data)) {
         if (isset($data['phone'])) {
             $query->andFilterWhere(['users.phone' => $data['phone']]);
         }
         if (isset($data['hobbyid'])) {
             $query->andFilterWhere(['hobbyid' => $data['hobbyid']]);
         }
         if (isset($data['content'])) {
             $query->andFilterWhere(['like', 'content', $data['content']]);
         }
     }
     $daters = $dataProvider->getModels();
     //$result = array ();
     //$result ['item'] = array ();
     //$tbreplys = (new \yii\db\Query ())->select('tbreplys.*,users.phone,users.nickname,users.thumb')->orderBy ( "tbreplys.created_at desc" )->join ( 'INNER JOIN', 'users', ' tbmessages.userid =users.id ')->where('tbreplys.messageid in ');
     foreach ($daters as $i => $dater) {
         $info = $dater;
         $info["distance"] = $this->getDistance($latitude, $longitude, $info['latitude'], $info['longitude']);
         $daters[$i] = $info;
     }
     $dataProvider->setModels($daters);
     return $dataProvider;
 }
Beispiel #16
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Grandchild::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /**
      * Setup your sorting attributes
      * Note: This is setup before the $this->load($params) 
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['parent_id', 'ParentsName' => ['asc' => ['fr001.parent' => SORT_ASC], 'desc' => ['fr001.parent' => SORT_DESC], 'label' => 'Parent Name'], 'ChildName' => ['asc' => ['fr000.CHILD_NAME' => SORT_ASC], 'desc' => ['fr000.CHILD_NAME' => SORT_DESC], 'label' => 'Child Name']]]);
     if (!($this->load($params) && $this->validate())) {
         /**
          * The following line will allow eager loading with country data 
          * to enable sorting by country on initial loading of the grid.
          */
         $query->joinWith(['parents']);
         $query->joinWith(['child']);
         return $dataProvider;
     }
     /* Add your filtering criteria */
     // filter by parent name
     $query->joinWith(['parents' => function ($q) {
         $q->where('fr001.parent LIKE "%' . $this->ParentsName . '%"');
     }]);
     return $dataProvider;
 }
Beispiel #17
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = WeatherAlert::find();
     $query->joinWith(['userReadAlerts.weatherAlert']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'magnitude', 'event', 'date', 'severity', 'stormName' => ['asc' => ['id' => SORT_ASC], 'desc' => ['id' => SORT_DESC], 'label' => 'Storm Name', 'default' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'magnitude' => $this->magnitude, 'identifier' => $this->identifier]);
     $query->andFilterWhere(['like', 'severity', $this->severity]);
     $query->andFilterWhere(['=', 'WeatherAlert.type', $this->type]);
     $query->andFilterWhere(['=', 'WeatherAlert.event', $this->event]);
     $query->andFilterWhere(['=', 'WeatherAlert.status', WeatherAlert::STATUS_ACTUAL]);
     //        var_dump(time() - Yii::$app->params['timePeriodForRecentAlerts']*3600);die;
     $timePeriodForAlert = $this->type == 0 ? Yii::$app->params['timePeriodForRecentPreAlerts'] : Yii::$app->params['timePeriodForRecentPostAlerts'];
     //        if ($this->type == 1) {
     //            var_dump($timePeriodForAlert);die;
     //        }
     $query->andFilterWhere(['>', 'WeatherAlert.date', time() - $timePeriodForAlert * 3600]);
     //        $query->addSelect('COUNT(UserReadAlerts.User_id)');
     //        $query->andFilterWhere(['=', 'UserReadAlerts.User_id', Yii::$app->user->id]);
     //        $query->andFilterWhere(['=', 'UserReadAlerts.WeatherAlert_id', $this->id]);
     //        if (!Yii::$app->request->isPjax) {
     //
     //        }
     $query->orderBy(['WeatherAlert.date' => SORT_DESC]);
     //        $query->orderBy(['UserReadAlerts.User_id'=>'DESC']);
     $query->groupBy(['WeatherAlert.id']);
     return $dataProvider;
 }
Beispiel #18
0
 /**
  * Returns categories.
  * @return Category[]
  */
 public function show()
 {
     $query = self::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->defaultOrder = ['sort' => SORT_ASC, 'id' => SORT_ASC];
     return $dataProvider->getModels();
 }
Beispiel #19
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Manager::find();
     // add conditions that should always apply here
     $query = $query->innerJoinWith('user');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['user_id', 'status', 'created_at', 'updated_at', 'username' => ['asc' => ['wy_user.username' => SORT_ASC], 'desc' => ['wy_user.username' => SORT_DESC], 'label' => 'Username'], 'userStatus' => ['asc' => ['wy_user.status' => SORT_ASC], 'desc' => ['wy_user.status' => SORT_DESC], 'label' => 'User Status']]]);
     $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;
     }
     if ($this->status == '合法') {
         $this->status = 1;
     } elseif ($this->status == '冻结') {
         $this->status = 2;
     }
     if ($this->userStatus == '合法') {
         $this->userStatus = 1;
     } elseif ($this->userStatus == '冻结') {
         $this->userStatus = 2;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'wy_manager.status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'wy_user.status' => $this->userStatus]);
     $query->andFilterWhere(['like', 'wy_user.username', $this->username]);
     return $dataProvider;
 }
Beispiel #20
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DataList::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /**
      * Настройка параметров сортировки
      * Важно: должна быть выполнена раньше $this->load($params)
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['id', 'id_device', 'deviceName' => ['asc' => ['device.name_device' => SORT_ASC], 'desc' => ['device.name_device' => SORT_DESC], 'label' => 'Прибор'], 'dataRef' => ['asc' => ['data_ref.name_ref' => SORT_ASC], 'desc' => ['data_ref.name_ref' => SORT_DESC]], 'number', 'time_point', 'work_data', 'typeDataRef' => ['asc' => ['data_ref.type_data_ref' => SORT_ASC], 'desc' => ['data_ref.type_data_ref' => SORT_DESC]]]]);
     if (!($this->load($params) && $this->validate())) {
         /**
          * Жадная загрузка данных типа приборов
          * для работы сортировки.
          */
         $query->joinWith(['idDevice']);
         $query->joinWith(['idDataRef']);
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['data_list.id' => $this->id, 'id_device' => $this->id_device, 'id_data_ref' => $this->id_data_ref, 'number' => $this->number, 'time_point' => $this->time_point, 'work_data' => $this->work_data]);
     // Фильтр по типу прибора
     $query->joinWith(['idDevice' => function ($q) {
         $q->andFilterWhere(['like', 'device.name_device', $this->deviceName]);
     }]);
     // Фильтр по типу данных
     $query->joinWith(['idDataRef' => function ($q) {
         $q->andFilterWhere(['like', 'data_ref.name_ref', $this->dataRef]);
         $q->andFilterWhere(['like', 'data_ref.type_data_ref', $this->typeDataRef]);
     }]);
     return $dataProvider;
 }
Beispiel #21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     /**
      * Setup your sorting attributes
      * Note: This is setup before the $this->load($params) 
      * statement below
      */
     $dataProvider->setSort(['attributes' => ['id', 'userIdLink' => ['asc' => ['user.id' => SORT_ASC], 'desc' => ['user.id' => SORT_DESC], 'label' => 'User'], 'userLink' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC], 'label' => 'User'], 'profileLink' => ['asc' => ['profile.id' => SORT_ASC], 'desc' => ['profile.id' => SORT_DESC], 'label' => 'Profile'], 'roleName' => ['asc' => ['role.role_name' => SORT_ASC], 'desc' => ['role.role_name' => SORT_DESC], 'label' => 'Role'], 'statusName' => ['asc' => ['status.status_name' => SORT_ASC], 'desc' => ['status.status_name' => SORT_DESC], 'label' => 'Status'], 'userTypeName' => ['asc' => ['user_type.user_type_name' => SORT_ASC], 'desc' => ['user_type.user_type_name' => SORT_DESC], 'label' => 'User Type'], 'created_at' => ['asc' => ['created_at' => SORT_ASC], 'desc' => ['created_at' => SORT_DESC], 'label' => 'Created At'], 'email' => ['asc' => ['email' => SORT_ASC], 'desc' => ['email' => SORT_DESC], 'label' => 'Email']]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['role'])->joinWith(['status'])->joinWith(['profile'])->joinWith(['userType']);
         return $dataProvider;
     }
     $this->addSearchParameter($query, 'id');
     $this->addSearchParameter($query, 'username', true);
     $this->addSearchParameter($query, 'email', true);
     $this->addSearchParameter($query, 'role_id');
     $this->addSearchParameter($query, 'status_id');
     $this->addSearchParameter($query, 'user_type_id');
     $this->addSearchParameter($query, 'created_at');
     $this->addSearchParameter($query, 'updated_at');
     // filter by role
     $query->joinWith(['role' => function ($q) {
         $q->andFilterWhere(['=', 'role.role_name', $this->roleName]);
     }])->joinWith(['status' => function ($q) {
         $q->andFilterWhere(['=', 'status.status_name', $this->statusName]);
     }])->joinWith(['userType' => function ($q) {
         $q->andFilterWhere(['=', 'user_type.user_type_name', $this->userTypeName]);
     }])->joinWith(['profile' => function ($q) {
         $q->andFilterWhere(['=', 'profile.id', $this->profileId]);
     }]);
     return $dataProvider;
 }
Beispiel #22
0
 public function actionLeaveAndOvertime()
 {
     $searchModel = new UserDateSearch();
     $dataProvider = $searchModel->searchUser(Yii::$app->request->queryParams, Yii::$app->user->id);
     //$dataProvider = Application::find()->where(['user_id'=>Yii::$app->user->id]);
     $query = Application::find();
     $query->joinWith(['user', 'reasonApplication']);
     $query->where(array('application.user_id' => Yii::$app->user->id, 'manager_ok' => 1, 'hrm_ok' => 1));
     $query->andWhere('type_id = 1 OR type_id = -1 OR type_id = -11');
     $query->orderBy(['from_date' => SORT_DESC]);
     $dataProviderUserTimeOver = new ActiveDataProvider(['query' => $query]);
     $totalTimeOverWork = 0;
     $totalTimeLeaveOfTimeOver = 0;
     $totalTimeMoney = 0;
     foreach ($dataProviderUserTimeOver->getModels() as $model) {
         if ($model->reasonApplication->type_id == 1) {
             $totalTimeOverWork += $model->hours_off;
         } else {
             if ($model->reasonApplication->type_id == -1) {
                 $totalTimeLeaveOfTimeOver += $model->hours_off;
             } else {
                 if ($model->reasonApplication->type_id == -11) {
                     $totalTimeMoney += $model->hours_off;
                 }
             }
         }
     }
     return $this->render('leave-and-overtime', ['dataProvider' => $dataProvider, 'dataUserTimeOver' => $dataProviderUserTimeOver, 'totalTimeOverWork' => $totalTimeOverWork, 'totalTimeLeaveOfTimeOver' => $totalTimeLeaveOfTimeOver, 'totalTimeMoney' => $totalTimeMoney, 'totalRemainTime' => $totalTimeOverWork - $totalTimeLeaveOfTimeOver - $totalTimeMoney]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Users::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $sort = $dataProvider->getSort();
     $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Имя офиса'];
     $dataProvider->setSort($sort);
     $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');
         $query->joinWith(['questionlist_office']);
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     if ($this->roleName) {
         $this->profile_office_role = $this->roleName;
     }
     $query->andFilterWhere(['like', 'profile_id', $this->profile_id])->andFilterWhere(['like', 'profile_office_role', 'manager']);
     $query->joinWith(['office' => function ($q) {
         $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]);
     }]);
     $query->joinWith(['region' => function ($q) {
         $q->andFilterWhere(['like', 'questionlist_region.name', $this->regionName]);
     }]);
     return $dataProvider;
 }
Beispiel #24
0
 public function search($params)
 {
     $query = SqlLogSearch::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['sqlusedtime']]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     if (isset($params['id'])) {
         $query->andWhere(['Id' => $params['id']]);
     }
     if (isset($params['SqlLogSearch']['start_date']) && !empty($params['SqlLogSearch']['start_date'])) {
         $query->andWhere(" executedate>=:start_date", [':start_date' => $params['SqlLogSearch']['start_date']]);
     }
     if (isset($params['SqlLogSearch']['end_date']) && !empty($params['SqlLogSearch']['end_date'])) {
         $query->andWhere(" executedate<=:end_date", [':end_date' => $params['SqlLogSearch']['end_date']]);
     }
     if (isset($params['SqlLogSearch']['sqltext']) && !empty($params['SqlLogSearch']['sqltext'])) {
         $query->andWhere(['like', 'sqltext', $params['SqlLogSearch']['sqltext']]);
     }
     if (!isset($params['sort'])) {
         $query->orderBy('executedate desc ');
     }
     return $dataProvider;
 }
 public function search($params)
 {
     $query = Profile::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'first_name', 'last_name', 'birthdate', 'genderName' => ['asc' => ['gender.gender_name' => SORT_ASC], 'desc' => ['gender.gender_name' => SORT_DESC], 'label' => 'Gender'], 'profileIdLink' => ['asc' => ['profile.id' => SORT_ASC], 'desc' => ['profile.id' => SORT_DESC], 'label' => 'ID'], 'userLink' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC], 'label' => 'User']]]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['gender'])->joinWith(['user']);
         return $dataProvider;
     }
     $this->addSearchParameter($query, 'id');
     $this->addSearchParameter($query, 'first_name', true);
     $this->addSearchParameter($query, 'last_name', true);
     $this->addSearchParameter($query, 'birthdate');
     $this->addSearchParameter($query, 'gender_id');
     $this->addSearchParameter($query, 'created_at');
     $this->addSearchParameter($query, 'updated_at');
     $this->addSearchParameter($query, 'user_id');
     // filter by gender name
     $query->joinWith(['gender' => function ($q) {
         $q->andFilterWhere(['=', 'gender.gender_name', $this->genderName]);
     }])->joinWith(['user' => function ($q) {
         $q->andFilterWhere(['=', 'user.id', $this->user]);
     }]);
     return $dataProvider;
 }
Beispiel #26
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Books::find()->with('author');
     // add conditions that should always apply here
     //$this->date_from = '21321';
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['attributes' => ['id', 'author_id' => ['asc' => ['authors.firstname' => SORT_ASC, 'authors.lastname' => SORT_ASC], 'desc' => ['authors.firstname' => SORT_DESC, 'authors.lastname' => SORT_DESC], 'label' => 'Автор', 'default' => SORT_ASC], 'date', 'date_create', 'name']]);
     if (!($this->load($params) && $this->validate())) {
         $query->joinWith(['author']);
         return $dataProvider;
     }
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'author_id' => $this->author_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     if (!empty($this->dateFrom)) {
         $query->andFilterWhere(['>=', 'date', $this->dateFrom]);
     }
     if (!empty($this->dateTo)) {
         $query->andFilterWhere(['<=', 'date', $this->dateTo]);
     }
     return $dataProvider;
 }
Beispiel #27
0
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Collection::find()->where(['author_id' => Yii::$app->user->id])]);
     $totalCount = $dataProvider->getTotalCount();
     $pages = new Pagination(['totalCount' => $totalCount]);
     return $this->render('index', ['models' => $dataProvider->getModels(), 'pages' => $pages]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = AnswerList::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $sort = $dataProvider->getSort();
     $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Отделение'];
     $sort->attributes['statusName'] = ['asc' => ['status' => SORT_ASC], 'desc' => ['status' => SORT_DESC], 'label' => 'Статус'];
     $dataProvider->setSort($sort);
     $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');
         $query->joinWith(['questionlist_office']);
         return $dataProvider;
     }
     $query->joinWith('questionList');
     $query->andFilterWhere(['id' => $this->id, 'question_list_id' => $this->question_list_id, 'scores' => $this->scores, 'date' => $this->date]);
     $query->andFilterWhere(['>=', 'date_from', $this->date_from])->andFilterWhere(['<=', 'date_to', $this->date_to]);
     if (!$this->statusName) {
         $query->andFilterWhere(['not like', 'status', 'archive']);
     } else {
         $query->andFilterWhere(['like', 'status', $this->statusName]);
     }
     $query->joinWith(['office' => function ($q) {
         $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]);
     }]);
     return $dataProvider;
 }
Beispiel #29
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Users::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $sort = $dataProvider->getSort();
     $sort->attributes['officeName'] = ['asc' => ['questionlist_office.name' => SORT_ASC], 'desc' => ['questionlist_office.name' => SORT_DESC], 'label' => 'Имя офиса'];
     $dataProvider->setSort($sort);
     $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');
         $query->joinWith(['questionlist_office']);
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     if ($this->roleName) {
         $this->profile_office_role = $this->roleName;
     }
     $query->andFilterWhere(['like', 'profile_id', $this->profile_id])->andFilterWhere(['like', 'profile_office_role', $this->profile_office_role]);
     if ($this->scenario == 'managerSearch') {
         $userRoles = Users::findAll(['profile_id' => Yii::$app->user->identity->username, 'profile_office_role' => 'commercial_director']);
         $userRegions = array_values(ArrayHelper::map($userRoles, 'region_id', 'region_id'));
         $query->andFilterWhere(['like', 'profile_office_role', 'manager']);
         $query->andFilterWhere(['in', 'questionlist_users_offices.region_id', $userRegions]);
     }
     $query->joinWith(['office' => function ($q) {
         $q->andFilterWhere(['like', 'questionlist_office.name', $this->officeName]);
     }]);
     $query->joinWith(['region' => function ($q) {
         $q->andFilterWhere(['like', 'questionlist_region.name', $this->regionName]);
     }]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Restaurant::find();
     if ($params['id']) {
         $query = Restaurant::find()->where('status!=0 and state !=4');
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['defaultOrder' => ['updatedOn' => SORT_DESC]]);
     //$query->andWhere("not ((`state`=".AppActiveRecord::STATUS_DRAFT.") AND (`createdBy`!=".\yii::$app->user->id."))");
     if (!($this->load($params) && $this->validate())) {
         $query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]);
         return $dataProvider;
     }
     if ($this->state !== null) {
         if ($this->state == AppActiveRecord::STATUS_DRAFT) {
             $query->andFilterWhere(['state' => $this->state, 'createdBy' => \yii::$app->user->id]);
         } else {
             $query->andFilterWhere(['state' => $this->state]);
         }
     } else {
         $query->andFilterWhere(['NOT', ['state' => AppActiveRecord::STATUS_DELETE]]);
     }
     $query->andFilterWhere(['Id' => $this->Id, 'sourceId' => $this->sourceId, 'chainId' => $this->chainId, 'cityId' => $this->cityId, 'localityId' => $this->localityId, 'zoneId' => $this->zoneId, 'pin' => $this->pin, 'entityType' => $this->entityType, 'gpsLat' => $this->gpsLat, 'gpsLong' => $this->gpsLong, 'priceForTwo' => $this->priceForTwo, 'capacity' => $this->capacity, 'coverFee' => $this->coverFee, 'entryFee' => $this->entryFee, 'ladiesFee' => $this->ladiesFee, 'hotelId' => $this->hotelId, 'status' => $this->status, 'healthStatus' => $this->healthStatus, 'popularityScore' => $this->popularityScore, 'popularityScroreParams' => $this->popularityScroreParams, 'createdBy' => $this->createdBy, 'updatedBy' => $this->updatedBy, 'createdOn' => $this->createdOn, 'updatedOn' => $this->updatedOn, 'popularpubs' => $this->popularpubs, 'launchdate' => $this->launchdate]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'landmark', $this->landmark])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'tollfree', $this->tollfree])->andFilterWhere(['like', 'phoneAlias', $this->phoneAlias])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'facebook', $this->facebook])->andFilterWhere(['like', 'owner', $this->owner])->andFilterWhere(['like', 'manager', $this->manager])->andFilterWhere(['like', 'tips', $this->tips])->andFilterWhere(['like', 'famousFor', $this->famousFor])->andFilterWhere(['like', 'guid', $this->guid])->andFilterWhere(['like', 'old_guid', $this->old_guid])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'ip', $this->ip])->andFilterWhere(['like', 'specialities', $this->specialities]);
     return $dataProvider;
 }