本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: getSort
public function getSort($className = 'CSort')
{
if (($sort = parent::getSort($className)) !== false) {
$sort->attributes = $this->attributes;
}
return $sort;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}