当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveDataProvider::getSort方法代码示例

本文整理汇总了PHP中yii\data\ActiveDataProvider::getSort方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveDataProvider::getSort方法的具体用法?PHP ActiveDataProvider::getSort怎么用?PHP ActiveDataProvider::getSort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\data\ActiveDataProvider的用法示例。


在下文中一共展示了ActiveDataProvider::getSort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: search

 /**
  * Default index search method
  * @param $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Message::find();
     $query->joinWith('source');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->getSort()->attributes['sourceMessage'] = ['asc' => ['source.message' => SORT_ASC], 'desc' => ['source.message' => SORT_DESC]];
     $dataProvider->getSort()->attributes['sourceCategory'] = ['asc' => ['source.category' => SORT_ASC], 'desc' => ['source.category' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     if ($this->translation) {
         $t = addslashes($this->translation);
         $query->where("translation like '%{$t}%'");
     }
     if ($this->translationUpdate === 'is null') {
         $query->where('translation is null');
     }
     if ($this->translationUpdate === 'is not null') {
         $query->where('translation is not null');
     }
     if ($this->translation) {
         $query->andWhere(['like', 'translation', '%' . $this->translation . '%', false]);
     }
     if ($this->sourceMessage) {
         $query->andFilterWhere(['like', 'source.message', $this->sourceMessage]);
     }
     if ($this->language) {
         $query->andWhere(['language' => $this->language]);
     }
     if ($this->sourceCategory) {
         $query->andFilterWhere(['like', 'source.category', $this->sourceCategory]);
     }
     return $dataProvider;
 }
开发者ID:bariew,项目名称:yii2-i18n-cms-module,代码行数:40,代码来源:MessageSearch.php

示例2: search

 public function search($params)
 {
     $query = Domicilio::find()->joinWith(['perfil', 'perfil.alumno'])->joinWith('pais')->joinWith('provincia')->joinWith('ciudad')->andWhere(['alumno.id' => $params['alumno_id']]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->getSort()->attributes = array_merge($dataProvider->getSort()->attributes, ['pais_nombre' => ['asc' => ['pais.nombre' => SORT_ASC], 'desc' => ['pais.nombre' => SORT_DESC], 'label' => Yii::t('app', 'País')], 'provincia_nombre' => ['asc' => ['provincia.nombre' => SORT_ASC], 'desc' => ['provincia.nombre' => SORT_DESC], 'label' => Yii::t('app', 'Provincia')], 'ciudad_nombre' => ['asc' => ['ciudad.nombre' => SORT_ASC], 'desc' => ['ciudad.nombre' => SORT_DESC], 'label' => Yii::t('app', 'Ciudad')]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'domicilio.principal' => $this->principal]);
     $query->andFilterWhere(['like', 'direccion', $this->direccion])->andFilterWhere(['like', 'cp', $this->cp])->andFilterWhere(['like', 'pais.nombre', $this->pais_nombre])->andFilterWhere(['like', 'provincia.nombre', $this->provincia_nombre])->andFilterWhere(['like', 'ciudad.nombre', $this->ciudad_nombre]);
     return $dataProvider;
 }
开发者ID:sacuriom,项目名称:alba2,代码行数:12,代码来源:AlumnoDomicilioSearch.php

示例3: search

 /**
  * @param array|null $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MarketOrder::find()->joinWith(['staStation', 'invTypes']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!$this->load($params) && !$this->validate()) {
         return $dataProvider;
     }
     $dataProvider->getSort()->attributes['stationName'] = ['asc' => ['staStations.stationName' => SORT_ASC], 'desc' => ['staStations.stationName' => SORT_DESC]];
     $dataProvider->getSort()->attributes['typeName'] = ['asc' => ['invTypes.typeName' => SORT_ASC], 'desc' => ['invTypes.typeName' => SORT_DESC]];
     $query->andFilterWhere(['stationID' => $this->stationID])->andFilterWhere(['like', 'stationName', $this->getAttribute('stationName')])->andFilterWhere(['like', 'typeName', $this->getAttribute('typeName')])->andFilterWhere(['orderState' => $this->orderState])->andFilterWhere(['characterID' => $this->characterID]);
     return $dataProvider;
 }
开发者ID:Sywooch,项目名称:EVE-Manager-Yii-2.x,代码行数:17,代码来源:SearchMarketOrder.php

示例4: search

 public function search($params)
 {
     $query = Provincia::find()->joinWith('pais');
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->getSort()->attributes = array_merge($dataProvider->getSort()->attributes, ['pais_nombre' => ['asc' => ['pais.nombre' => SORT_ASC], 'desc' => ['pais.nombre' => SORT_DESC], 'label' => Yii::t('app', 'País')]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'pais.nombre', $this->pais_nombre]);
     return $dataProvider;
 }
开发者ID:sacuriom,项目名称:alba2,代码行数:12,代码来源:ProvinciaSearch.php

示例5: getSort

 public function getSort($className = 'CSort')
 {
     if (($sort = parent::getSort($className)) !== false) {
         $sort->attributes = $this->attributes;
     }
     return $sort;
 }
开发者ID:mpenicaud,项目名称:php-mongo-yii,代码行数:7,代码来源:DataProvider.php

示例6: search

 /**
  * 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;
 }
开发者ID:igribov,项目名称:question-list,代码行数:40,代码来源:UsersSearch.php

示例7: search

 /**
  * Creates data provider instance with search query applied
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = self::find()->select(['user.*', "CONCAT(user.first_name,' ', user.last_name) AS fullName"])->from(['user' => static::tableName()]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->getSort()->attributes += ['fullName' => ['asc' => ['fullName' => SORT_ASC], 'desc' => ['fullName' => 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(['user.id' => $this->id, 'user.logins_count' => $this->logins_count, 'user.is_active' => $this->is_active]);
     $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'user.password', $this->password])->andFilterWhere(['like', "CONCAT(user.first_name,' ', user.last_name)", $this->fullName])->andFilterWhere(['like', 'user.phone', $this->phone]);
     if (!empty($this->created_at)) {
         $range = explode(' - ', $this->created_at);
         if (!empty($range[0]) && !empty($range[1])) {
             $query->andWhere('user.created_at BETWEEN :prt1 AND :prt2', [':prt1' => strtotime($range[0]), ':prt2' => strtotime($range[1])]);
         }
     }
     if (!empty($this->last_login_at)) {
         $range = explode(' - ', $this->last_login_at);
         if (!empty($range[0]) && !empty($range[1])) {
             $query->andWhere('user.last_login_at BETWEEN :prt3 AND :prt4', [':prt3' => strtotime($range[0]), ':prt4' => strtotime($range[1])]);
         }
     }
     return $dataProvider;
 }
开发者ID:vfokov,项目名称:tims2,代码行数:32,代码来源:User.php

示例8: search

 /**
  * 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;
 }
开发者ID:igribov,项目名称:question-list,代码行数:34,代码来源:ManagersSearch.php

示例9: search

 /**
  * 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;
 }
开发者ID:igribov,项目名称:question-list,代码行数:35,代码来源:AnswerListSearch.php

示例10: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Value::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['attribute'] = ['asc' => [Attribute::tableName() . '.presentation' => SORT_ASC], 'desc' => [Attribute::tableName() . '.presentation' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         $dataProvider->getSort() !== false ? $query->joinWith(['eAttribute']) : $query->with('eAttribute');
         return $dataProvider;
     } else {
         $query->joinWith(['eAttribute']);
     }
     $query->andFilterWhere(['like', 'value', $this->value]);
     $query->andFilterWhere(['like', Attribute::tableName() . '.presentation', $this->attribute]);
     return $dataProvider;
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:22,代码来源:ValueSearch.php

示例11: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ProductType::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->sort->attributes['parentName'] = ['asc' => ['parent.name' => SORT_ASC], 'desc' => ['parent.name' => SORT_DESC]];
     if (!($this->load($params) && $this->validate())) {
         $dataProvider->getSort() !== false ? $query->joinWith(['parentRelation']) : $query->with('parentRelation');
         return $dataProvider;
     } else {
         $query->joinWith(['parentRelation']);
     }
     $query->andFilterWhere(['like', '{{%product_types}}.name', $this->name]);
     $query->andFilterWhere(['like', 'parent.name', $this->parentName]);
     return $dataProvider;
 }
开发者ID:manyoubaby123,项目名称:imshop,代码行数:22,代码来源:ProductTypeSearch.php

示例12: search

 /**
  * Searching menu
  *
  * @param  array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = self::find()->from(self::tableName());
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $sort = $dataProvider->getSort();
     $sort->attributes['name'] = ['asc' => ['name' => SORT_ASC], 'desc' => ['name' => SORT_DESC], 'label' => 'name'];
     $sort->attributes['locale'] = ['asc' => ['locale' => SORT_ASC], 'desc' => ['locale' => SORT_DESC], 'label' => 'locale'];
     $sort->attributes['url'] = ['asc' => ['url' => SORT_ASC], 'desc' => ['url' => SORT_DESC], 'label' => 'url'];
     $sort->defaultOrder = ['name' => SORT_ASC];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'lower(name)', strtolower($this->name)])->andFilterWhere(['like', 'lower(locale)', strtolower($this->locale)])->andFilterWhere(['like', 'lower(url)', strtolower($this->url)]);
     return $dataProvider;
 }
开发者ID:gbksoft,项目名称:yii2-multilingual,代码行数:21,代码来源:Language.php

示例13: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = $this->find()->select(['id' => 'record.id', 'license' => 'record.license', 'lat' => 'record.lat', 'lng' => 'record.lng', 'state_id' => 'record.state_id', 'infraction_date' => 'record.infraction_date', 'created_at' => 'record.created_at', 'elapsedTime' => self::SQL_SELECT_ELAPSED_TIME, 'fullName' => self::SQL_SELECT_FULL_NAME])->from(['record' => static::tableName()])->joinWith(['user' => function ($query) {
         $query->from('User user');
     }]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->getSort()->attributes['fullName'] = ['asc' => ['fullName' => SORT_ASC], 'desc' => ['fullName' => SORT_DESC]];
     $dataProvider->getSort()->attributes['created_at'] = ['asc' => ['record.created_at' => SORT_ASC], 'desc' => ['record.created_at' => SORT_DESC]];
     $dataProvider->getSort()->attributes['elapsedTime'] = ['asc' => ['elapsedTime' => SORT_ASC], 'desc' => ['elapsedTime' => 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, 'user_id' => $this->user_id, 'state_id' => $this->state_id, 'infraction_date' => $this->infraction_date, 'record.created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'license', $this->license])->andFilterWhere(['like', 'lat', $this->lat])->andFilterWhere(['like', 'lng', $this->lng]);
     $query->andFilterWhere(['like', self::SQL_SELECT_FULL_NAME, $this->fullName]);
     $query->andFilterWhere(['like', self::SQL_SELECT_ELAPSED_TIME, $this->elapsedTime]);
     if ($statuses = $this->getAvailableStatuses()) {
         $query->andFilterWhere(['in', 'status_id', $statuses]);
     }
     return $dataProvider;
 }
开发者ID:vfokov,项目名称:tims2,代码行数:31,代码来源:Record.php

示例14: search

 public function search($params)
 {
     $query = Card::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         //            $query->joinWith('cardStatus');
         return $dataProvider;
     }
     $sort = $dataProvider->getSort();
     $sort->attributes['attributes']['status'] = ['asc' => ['card.status' => SORT_ASC], 'desc' => ['card.status' => SORT_DESC], 'label' => 'Статус', 'default' => SORT_ASC];
     $dataProvider->setSort($sort);
     $query->andFilterWhere(['no' => $this->no, 'creation_date' => $this->creation_date, 'deactivation_date' => $this->deactivation_date, 'activity_date' => $this->activity_date, 'sum' => $this->sum, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'sn', $this->sn]);
     return $dataProvider;
 }
开发者ID:riros,项目名称:tests,代码行数:15,代码来源:SearchCard.php

示例15: search

 public function search($params)
 {
     $query = MenuModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->leftJoin(['parent' => '{{%menu}}'], '{{%menu}}.parent=parent.id');
     $sort = $dataProvider->getSort();
     $sort->attributes['menuParent.name'] = ['asc' => ['parent.name' => SORT_ASC], 'desc' => ['parent.name' => SORT_DESC], 'label' => 'parent'];
     $sort->attributes['order'] = ['asc' => ['parent.order' => SORT_ASC, '{{%menu}}.order' => SORT_ASC], 'desc' => ['parent.order' => SORT_DESC, '{{%menu}}.order' => SORT_DESC], 'label' => 'order'];
     $sort->defaultOrder = ['menuParent.name' => SORT_ASC];
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent' => $this->parent]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'route', $this->route])->andFilterWhere(['like', 'parent.name', $this->parent_name]);
     return $dataProvider;
 }
开发者ID:hscstudio,项目名称:yii2-heart,代码行数:16,代码来源:Menu.php


注:本文中的yii\data\ActiveDataProvider::getSort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。