<?php
    
    use common\models\CategoryToPurpose;
    use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel common\models\CategoryToPurposeSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', 'Category To Purposes');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-to-purpose-index">

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

    <p>
        <?= Html::a(Yii::t('app', 'Create Category To Purpose'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            [
                'attribute' => 'category_id',
                'value' => function($model) {
                    /**
                     * @var CategoryToPurpose $model
                     */
                    return $model->category->lang->name;
                }
            ],
            [
                'attribute' => 'purpose_id',
                'value' => function($model) {
                    /**
                     * @var CategoryToPurpose $model
                     */
                    return $model->purpose->lang->value;
                }
            ],
            [
                'attribute' => 'image',
                'value' => 'imageUrl',
                'format' => 'image',
            ],

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
