<?php

use yii\helpers\Html;
use yii\grid\GridView;
use app\models\Category;

/* @var $this yii\web\View */
/* @var $searchModel app\models\SubscriptionsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Subscriptions');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="subscriptions-index">

    <div class="panel panel-primary">
        <div class="panel-heading"><span class="glyphicon glyphicon-th"></span><strong> <?= Html::encode($this->title) ?></strong></div>
        <div class="panel-body">

            <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'filterModel' => $searchModel,
                'columns' => [
                    [
                        'attribute' => 'fio',
                        'value' => 'user.fio',
                        'visible' => Yii::$app->user->can('admin'),
                    ],
                    [
                        'attribute' => 'email',
                        'value' => 'user.email',
                        'visible' => Yii::$app->user->can('admin'),
                    ],
                    [
                        'attribute' => 'category_id',
                        'value' => 'category.name',
                        'filter' => \yii\helpers\ArrayHelper::map(Category::find()->all(), 'id', 'name')
                    ],
                    'created_at:datetime',

                    ['class' => 'yii\grid\ActionColumn', 'template' => '{delete}'],
                ],
            ]); ?>

        </div>
    </div>
</div>
