62d73041
xu
app-wx
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
<?php
namespace app\wx\helpers;
use yii;
use yii\data\Sort as dataSort;
/**
* Class Sort
* @package app\wx\helpers
*/
class Sort extends dataSort
{
/**
* @param $model
* @param array $extraAttrbutes
*/
public function setAttributes($model, $extraAttrbutes = [])
{
foreach ($model->attributes() as $attribute) {
$this->attributes[$attribute] = [
'asc' => [$attribute => SORT_ASC],
'desc' => [$attribute => SORT_DESC],
'label' => $model->getAttributeLabel($attribute),
];
}
if ($extraAttrbutes) {
foreach ($extraAttrbutes as $k => $label) {
$this->attributes[$k] = [
'asc' => [$k => SORT_ASC],
'desc' => [$k => SORT_DESC],
'label' => $label,
];
}
}
}
}
|