<?php

use yii\helpers\{Html, Url};
use yii\data\ArrayDataProvider;
use common\widgets\{ActionColumn, GridView};

$dataProvider = new ArrayDataProvider([
    'allModels' => $model->alladdresses,
]);
?>

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'rowOptions' => function ($dataModel) {
        return [
            'id' => $dataModel->id,
        ];
    },
    'columns' => [
        [
            'class' => ActionColumn::class,
            'controller' => 'address',
            'urlCreator' => function ($action, $dataModel, $key, $index) {
                return match ($action) {
                    'view' => Url::to(['/address/view', 'id' => $dataModel->id]),
                    'update' => Url::to(['/address/update', 'id' => $dataModel->id]),
                    'delete' => Url::to(['/address/delete', 'id' => $dataModel->id]),
                };
            }
        ],
        'name',
        'address1',
        'address2',
        'town',
        'county',
        'country',
        'postcode',
        'phone',
    ],
]);
