PlanActionsMenu::items()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 0
cts 23
cp 0
rs 9.552
c 0
b 0
f 0
cc 2
nc 2
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\menus;
12
13
use Yii;
14
15
class PlanActionsMenu extends \hiqdev\yii2\menus\Menu
16
{
17
    public $model;
18
19
    public function items()
20
    {
21
        return [
22
            'view' => [
23
                'label' => Yii::t('hipanel', 'View'),
24
                'icon' => 'fa-info',
25
                'url' => ['@plan/view', 'id' => $this->model->id],
26
                'linkOptions' => [
27
                    'data-pjax' => 0,
28
                ],
29
                'visible' => Yii::$app->user->can('plan.read'),
30
            ],
31
            'update' => [
32
                'label' => Yii::t('hipanel', 'Update'),
33
                'icon' => 'fa-pencil',
34
                'url' => ['@plan/update', 'id' => $this->model->id],
35
                'linkOptions' => [
36
                    'data-pjax' => 0,
37
                ],
38
                'visible' => Yii::$app->user->can('plan.update') && !$this->model->your_tariff,
39
            ],
40
        ];
41
    }
42
}
43