diff --git a/models/TaxGroupSearch.php b/models/TaxGroupSearch.php index aa1739d..46966c4 100755 --- a/models/TaxGroupSearch.php +++ b/models/TaxGroupSearch.php @@ -14,6 +14,10 @@ public $groupName; + public $alias; + + public $description; + public function behaviors() { $behaviors = parent::behaviors(); @@ -33,6 +37,7 @@ [ 'id', 'level', + 'sort', ], 'integer', ], @@ -45,6 +50,8 @@ [ [ 'groupName', + 'alias', + 'description', ], 'safe', ], @@ -67,7 +74,7 @@ * * @return ActiveDataProvider */ - public function search($params, int $level = null) + public function search($params, int $level = NULL) { $query = TaxGroup::find() ->joinWith('lang'); @@ -78,11 +85,20 @@ 'sort' => [ 'attributes' => [ 'id', + 'sort', 'is_filter', - 'groupName' => [ + 'groupName' => [ 'asc' => [ 'tax_group_lang.title' => SORT_ASC ], 'desc' => [ 'tax_group_lang.title' => SORT_DESC ], ], + 'alias' => [ + 'asc' => [ 'tax_group_lang.alias' => SORT_ASC ], + 'desc' => [ 'tax_group_lang.alias' => SORT_DESC ], + ], + 'description' => [ + 'asc' => [ 'tax_group_lang.description' => SORT_ASC ], + 'desc' => [ 'tax_group_lang.description' => SORT_DESC ], + ], ], ], ] @@ -105,6 +121,7 @@ 'id' => $this->id, 'is_filter' => $this->is_filter, 'level' => $this->level, + 'sort' => $this->sort, ] ) ->andFilterWhere( @@ -113,6 +130,20 @@ 'tax_group_lang.title', $this->groupName, ] + ) + ->andFilterWhere( + [ + 'ilike', + 'tax_group_lang.alias', + $this->alias, + ] + ) + ->andFilterWhere( + [ + 'ilike', + 'tax_group_lang.description', + $this->description, + ] ); return $dataProvider; diff --git a/views/tax-group/index.php b/views/tax-group/index.php index 493bbd9..1de87bd 100755 --- a/views/tax-group/index.php +++ b/views/tax-group/index.php @@ -41,7 +41,7 @@ 'filterModel' => $searchModel, 'columns' => [ [ 'class' => 'yii\grid\SerialColumn' ], - 'id', + 'sort', [ 'attribute' => 'is_filter', 'format' => 'boolean', @@ -52,22 +52,12 @@ 'value' => 'lang.title', ], [ - 'label' => \Yii::t('rubrication', 'Options count'), - 'value' => function ($model) { - /** - * @var TaxGroup $model - */ - return count($model->options); - }, + 'attribute' => 'alias', + 'value' => 'lang.alias' ], [ - 'label' => \Yii::t('rubrication', 'Categories count'), - 'value' => function ($model) { - /** - * @var TaxGroup $model - */ - return count($model->categories); - }, + 'attribute' => 'description', + 'value' => 'lang.description' ], [ 'class' => 'yii\grid\ActionColumn', -- libgit2 0.21.4