index.php 1.83 KB
<?php
    
    use artbox\core\models\Page;
    use artbox\core\models\PageSearch;
    use yii\helpers\Html;
    use yiister\gentelella\widgets\grid\GridView;
    use yiister\gentelella\widgets\Panel;
    
    /**
     * @var  yii\web\View                $this
     * @var  PageSearch                  $searchModel
     * @var  yii\data\ActiveDataProvider $dataProvider
     */
    
    $this->title = \Yii::t('core', 'Pages');
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="page-index">
    <?php
        $xPanel = Panel::begin(
            [
                'header' => $this->title,
            ]
        );
    ?>
    
    
    <p>
        <?= Html::a(
            \Yii::t('core', 'Create {item}', [ 'item' => \Yii::t('core', 'Page') ]),
            [ 'create' ],
            [ 'class' => 'btn btn-success' ]
        ) ?>
    </p>
    <?= GridView::widget(
        [
            'dataProvider' => $dataProvider,
            'filterModel'  => $searchModel,
            'columns'      => [
                'id',
                [
                    'attribute' => 'title',
                    'value'     => 'lang.title',
                ],
                [
                    'attribute' => 'in_menu',
                    'value'     => function ($model) {
                        /**
                         * @var Page $model
                         */
                        return ( !$model->in_menu ) ? \Yii::t('core', 'Не в меню') : \Yii::t('core', 'В меню');
                    },
                    'filter'    => [
                        0 => \Yii::t('core', 'Не в меню'),
                        1 => \Yii::t('core', 'В меню'),
                    ],
                ],
                [ 'class' => 'yii\grid\ActionColumn' ],
            ],
        ]
    ); ?>
    <?php
        $xPanel::end();
    ?>
</div>