<?php

namespace App\Http\Requests\Estimate;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'estimate_name' => 'sometimes|required|string|max:255',
            'customer_name' => 'nullable|string|max:255',
            'project_name' => 'nullable|string|max:255',
            'parameters' => 'sometimes|required|array',
            'parameters.*' => 'required',
            'notes' => 'nullable|string|max:2000',
            'status' => 'sometimes|in:DRAFT,SENT,APPROVED,REJECTED,EXPIRED',
        ];
    }

    public function messages(): array
    {
        return [
            'estimate_name.required' => __('validation.required', ['attribute' => '견적명']),
            'parameters.required' => __('validation.required', ['attribute' => '견적 파라미터']),
            'parameters.array' => __('validation.array', ['attribute' => '견적 파라미터']),
            'status.in' => __('validation.in', ['attribute' => '상태']),
        ];
    }
}
