<?php

namespace PortalPeople\shippingcosts\models;

use yii\base\Model;
use yii\web\UploadedFile;

class PriceUploadForm extends Model
{
    /** @var UploadedFile|null */
    public $priceFile;

    public function rules(): array
    {
        return [
            [['priceFile'], 'required'],
            [['priceFile'], 'file',
                'extensions'  => ['xlsx', 'xls'],
                'mimeTypes'   => [
                    'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
                    'application/vnd.ms-excel',
                ],
                'maxSize'     => 1024 * 1024 * 20, // 20 MB
                'checkExtensionByMimeType' => false,
            ],
        ];
    }

    public function attributeLabels(): array
    {
        return [
            'priceFile' => 'Pricing Spreadsheet (.xlsx / .xls)',
        ];
    }
}
