<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class StoreGrapeVarietyRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        // TODO: Implement authorization logic (check if user has permission to create grape varieties)
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'variety_name' => ['required', 'string', 'max:255', 'unique:grape_varieties,variety_name'],
            'description' => ['nullable', 'string'],
            'origin' => ['nullable', 'string', 'max:255'],
            'wine_type' => ['nullable', 'in:red,white,rose'],
            'characteristics' => ['nullable', 'string'],
            'image_url' => ['nullable', 'url', 'max:500'],
        ];
    }

    /**
     * Get custom attribute names for validator errors.
     *
     * @return array<string, string>
     */
    public function attributes(): array
    {
        return [
            'variety_name' => 'variety name',
            'wine_type' => 'wine type',
            'image_url' => 'image URL',
        ];
    }
}
