<?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;
?>
<div class="admin-log-index">

    <div class="box box-success">
        <div class="box-body">
            <?= GridView::widget([
                'dataProvider' => $dataProvider,
                'columns' => [
                    'id',
                    'route',
                    [
                        'attribute' => 'user_id',
                        'format' => 'raw',
                        'value' => function ($model) {
                            /* @var \common\models\AdminLog $model */
                            if ($model->user) {
                                return Html::a($model->user->nickname, \yii\helpers\Url::to(['/user/default/update', 'id' => $model->user_id]), ['title' => '查看用户', 'data-toggle' => 'tooltip', 'target' => '_blank']);
                            }

                            return '';
                        }
                    ],
                    [
                        'attribute' => 'ip',
                        'value' => function ($model) {
                            return long2ip($model->ip);
                        }
                    ],
                    'created_at:datetime',

                    [
                        'class' => 'common\helpers\DiyActionColumn',
                        'template' => '{view}'
                    ],
                ],
            ]); ?>
        </div>
    </div>

</div>
