<?php

declare(strict_types=1);

namespace App\Http\Requests\Asset;

use App\Enums\AssetDocumentType;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class StoreAssetDocumentRequest extends FormRequest
{
    public function authorize(): bool
    {
        return $this->user() !== null;
    }

    /**
     * @return array<string, array<int, mixed>>
     */
    public function rules(): array
    {
        return [
            'document' => ['required', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:10240'],
            'document_type' => ['required', Rule::enum(AssetDocumentType::class)],
        ];
    }

    /**
     * @return array<string, string>
     */
    public function messages(): array
    {
        return [
            'document.mimes' => __('The document must be a PDF, JPG or PNG file.'),
            'document.max' => __('The document cannot be larger than 10 MB.'),
        ];
    }
}
