<?php

namespace App\Http\Requests\Api\V1;

use Illuminate\Foundation\Http\FormRequest;

class FileUploadRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        $maxFileSize = config('filesystems.file_constraints.max_file_size', 20971520); // 20MB default
        $allowedExtensions = implode(',', config('filesystems.file_constraints.allowed_extensions', []));

        return [
            'file' => [
                'required',
                'file',
                'max:'.($maxFileSize / 1024), // KB
                'mimes:'.$allowedExtensions,
            ],
            'description' => 'nullable|string|max:500',
        ];
    }

    public function messages(): array
    {
        return [
            'file.required' => __('error.file_required'),
            'file.file' => __('error.file_invalid'),
            'file.max' => __('error.file_too_large'),
            'file.mimes' => __('error.file_type_not_allowed'),
        ];
    }
}
