<?php
use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
?>
<div class="blog-bid-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'email',
            [
                'attribute' => 'sent',
                'value' => function($model) {
                        return ($model->sent==1) ? 'Отправлено' : 'Не отправлено';
                    }
            ],
            [
                'attribute' => 'post_id',
                'value' => function($model) {
                        return $model->post->lang->title;
                    }
            ],
            [
                'attribute' => 'date',
                'value' => function($model) {
                        $dateNow = new \DateTime();
                        $date = new \DateTime($model->date);
                        return ($date>$dateNow) ? 'Планируемая дата отправки: '.$date->format('d.m.Y') : $date->format('d.m.Y');
                    }
            ],
//            [
//                'class' => 'yii\grid\ActionColumn',
//                'template' => '{update}{delete}',
//            ],
        ],
    ]); ?>
</div>
