TariffGridView::columns()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 24

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 24
ccs 0
cts 23
cp 0
rs 9.536
c 0
b 0
f 0
cc 2
nc 1
nop 0
crap 6
1
<?php
2
/**
3
 * Finance module for HiPanel
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-finance
6
 * @package   hipanel-module-finance
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\finance\grid;
12
13
use hipanel\grid\RefColumn;
14
use hipanel\helpers\Url;
15
use Yii;
16
17
class TariffGridView extends \hipanel\grid\BoxedGridView
18
{
19
    public function columns()
20
    {
21
        return array_merge(parent::columns(), [
22
            'tariff' => [
23
                'class' => 'hipanel\grid\MainColumn',
24
                'filterAttribute' => 'tariff_like',
25
                'note' => Yii::$app->user->can('tariff.update') ? 'note' : null,
26
                'noteOptions' => [
27
                    'url' => Url::to('set-note'),
28
                ],
29
            ],
30
            'used' => [
31
                'filter' => false,
32
            ],
33
            'type' => [
34
                'class' => RefColumn::class,
35
                'i18nDictionary' => 'hipanel:finance:tariff:types',
36
                'gtype' => 'type,tariff',
37
                'value' => function ($model) {
38
                    return Yii::t('hipanel:finance:tariff:types', $model->type);
39
                },
40
            ],
41
        ]);
42
    }
43
}
44