<?php

use yii\grid\GridView;
use yii\helpers\Html;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '用户';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php $this->beginBlock('content-header') ?>
<?= $this->title . ' ' . Html::a('新用户', ['create'], ['class' => 'btn btn-primary btn-flat btn-xs']) ?>
<?php $this->endBlock() ?>

<!--搜索-->
<?php echo $this->render('_search', ['model' => $searchModel]); ?>


<div class="box box-primary">
    <div class="box-body">
        <?= GridView::widget([
            'dataProvider' => $dataProvider,
//            'filterModel' => $searchModel,
            'columns' => [
                'id',
                'pid',
                'nickname',
                [
                    'attribute' => 'avatar',
                    "format" => [
                        "image", [
                            "width" => "60",
                            "height" => "60",
                            "class" => 'img-circle'
                        ]
                    ]
                ],
//                'dataCount[0][count]:text:日课',
                [
                    'label' => '日课',
                    'format' => 'raw',
                    'value' => function ($model) {
                        return $model->dataCount[0]['count'];
                    },
                ],
                [
                    'label' => '总课',
                    'format' => 'raw',
                    'value' => function ($model) {
                        return $model->dataCount[1]['count'];
                    },
                ],
                [
                    'label' => '辅助课',
                    'format' => 'raw',
                    'value' => function ($model) {
                        return $model->dataCount[2]['count'];
                    },
                ],
                'allRoleDesc:text:角色',
                'tel',
                'email',
                'created_at:datetime',
                'login_at:datetime',

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