Issues (42)

src/views/profiles/view.php (1 issue)

1
<?php
2
3
use yii\web\View;
4
use yii\helpers\{Html, Url};
5
use yii\widgets\DetailView;
6
use Itstructure\RbacModule\Module;
7
use Itstructure\RbacModule\interfaces\RbacIdentityInterface;
8
9
/* @var $this View */
10
/* @var $model RbacIdentityInterface */
11
12
$this->title = Module::t('profiles', 'Profile') . ': ' . $model->userName;
13
$this->params['breadcrumbs'][] = [
14
    'label' => Module::t('profiles', 'Profiles'),
15
    'url' => [
16
        $this->params['urlPrefix'].'index'
17
    ]
18
];
19
$this->params['breadcrumbs'][] = $this->title;
20
?>
21
<div class="profile-view">
22
23
    <p>
24
        <?php echo Html::a(Module::t('main', 'Update'), [
25
            $this->params['urlPrefix'].'update',
26
            'id' => $model->id
27
        ], [
28
            'class' => 'btn btn-primary'
29
        ]) ?>
30
31
        <?php echo Html::a(Module::t('main', 'Delete'), [
32
            $this->params['urlPrefix'].'delete',
33
            'id' => $model->id
34
        ], [
35
            'class' => 'btn btn-danger',
36
            'data' => [
37
                'confirm' => Module::t('main', 'Are you sure you want to do this action?'),
38
                'method' => 'post',
39
            ],
40
        ]) ?>
41
    </p>
42
43
    <?php echo DetailView::widget([
44
        'model' => $model,
45
        'attributes' => [
46
            'id' => [
47
                'attribute' => 'id',
48
                'label' => Module::t('main', 'ID')
49
            ],
50
            'userName' => [
51
                'attribute' => 'userName',
52
                'label' => Module::t('profiles', 'Name')
53
            ],
54
            'roles' => [
55
                'label' => Module::t('profiles', 'Roles'),
56
                'value' => function($model) {
57
                    /* @var $model RbacIdentityInterface */
58
                    $roles = $model->getRoles();
59
60
                    if (empty($roles)) {return Module::t('profiles', 'No roles');}
61
62
                    return implode('<br>', array_map(function ($data) {
63
64
                        return Html::a($data, Url::to([
65
                            '/'.$this->params['urlPrefixNeighbor'].'view',
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $this seems to be never defined.
Loading history...
66
                            'id' => $data
67
                        ]),
68
                            [
69
                                'target' => '_blank'
70
                            ]);
71
72
                    }, array_keys($roles)));
73
                },
74
                'format' => 'raw',
75
            ],
76
            'created_at' => [
77
                'attribute' => 'created_at',
78
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
79
                'label' => Module::t('main', 'Created date')
80
            ],
81
            'updated_at' => [
82
                'attribute' => 'updated_at',
83
                'format' =>  ['date', 'dd.MM.Y HH:mm:ss'],
84
                'label' => Module::t('main', 'Updated date')
85
            ],
86
        ]
87
    ]) ?>
88
89
</div>
90