index.php 1.78 KB
<?php
    
    use common\models\Persone;
    use common\models\PersoneSearch;
    use yii\data\ActiveDataProvider;
    use yii\helpers\Html;
    use yii\grid\GridView;
    use yii\web\View;
    use yiister\gentelella\widgets\Panel;
    
    /**
     * @var View               $this
     * @var ActiveDataProvider $dataProvider
     * @var PersoneSearch      $searchModel
     */
    
    $this->title = Yii::t('app', 'Persones');
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="persone-index">
    
    <?php Panel::begin(
        [
            'header' => $this->title,
        ]
    ) ?>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  
  <p>
      <?= Html::a(Yii::t('app', 'Create Persone'), [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
  </p>
    <?= GridView::widget(
        [
            'dataProvider' => $dataProvider,
            'filterModel'  => $searchModel,
            'columns'      => [
                [ 'class' => 'yii\grid\SerialColumn' ],
                
                'lang.title',
                [
                    'attribute' => 'image_id',
                    'value'     => function (Persone $model) {
                        if (!empty($model->image)) {
                            return Html::img(
                                $model->image->getUrl(),
                                [
                                    'width' => '500px',
                                ]
                            );
                        } else {
                            return '';
                        }
                    },
                    'format' => 'html',
                ],
                
                [ 'class' => 'yii\grid\ActionColumn' ],
            ],
        ]
    ); ?>
    <?php Panel::end() ?>
</div>