<?php

namespace PortalPeople\gforce\models;

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

/**
 * RateUploadForm
 *
 * Simple upload form for a GForce pricing spreadsheet.
 * Validates that the uploaded file is an xlsx / xls file under the size limit.
 */
class RateUploadForm extends Model
{
    /** @var UploadedFile|null */
    public $priceFile;

    public function rules(): array
    {
        return [
            [
                ['priceFile'],
                'file',
                'skipOnEmpty'    => false,
                'extensions'     => ['xlsx', 'xls'],
                'maxSize'        => 20 * 1024 * 1024,
                'tooBig'         => 'The file must be under 20 MB.',
                'wrongExtension' => 'Only .xlsx and .xls files are accepted.',
            ],
        ];
    }

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