<?php
    /**
     * @var Product  $model
     * @var mixed    $key
     * @var integer  $index
     * @var ListView $widget
     */
    use common\components\artboximage\ArtboxImageHelper;
    use common\modules\product\models\Product;
    use common\modules\product\models\ProductVariant;
    use yii\helpers\Html;
    use yii\widgets\ListView;
    
    $main_image = ArtboxImageHelper::getImage('/storage/no-image.png', 'filter_image');
    if(!empty( $model->variants )) {
        $variants = $model->variants;
        /**
         * @var ProductVariant $variant
         */
        $variant = current($variants);
        $main_image = ArtboxImageHelper::getImage($variant->getImageUrl(), 'filter_image');
        unset( $variant );
    }
?>
<div class="style brand-list-desc">
    <div class="section-box box-title-1">
        <?php
            echo $model->brand->lang->name . ' ' . $model->lang->name;
        ?>
    </div>
    <div class="col-xs-12 col-sm-3 col-md-3 col-lg-3">
        <?php
            echo Html::a($main_image, [
                'collection/index',
                'id' => $model->product_id,
            ]);
        ?>
    </div>
    <div class="col-xs-12 col-sm-6 col-md-5 col-lg-3">
        <div class="brand-list-desc-txt">
            <?php
                echo $model->lang->description;
            ?>
            <p>
                <?php
                    echo Html::a(\Yii::t('app', 'подробнее'), [
                        'collection/index',
                        'id' => $model->product_id,
                    ]);
                ?>
            </p>
        </div>
    </div>
</div>
<ul class="style brands-list">
    <?php
        foreach($model->variants as $variant) {
            ?>
            <li>
                <?php
                    echo Html::a(Html::tag('div', ArtboxImageHelper::getImage($variant->getImageUrl(), 'brand_collection_variant')) . Html::tag('p', $variant->lang->name), [
                        'collection/view',
                        'collection_id' => $model->product_id,
                        'variant_id'    => $variant->product_variant_id,
                    ]);
                ?>
            </li>
            <?php
        }
    ?>
</ul>