<?php

namespace App\Http\Requests\Construction;

use App\Models\Construction\StructureReview;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

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

    public function rules(): array
    {
        return [
            // 검토 정보
            'review_number' => 'nullable|string|max:50',

            // 거래처 정보
            'partner_id' => 'nullable|integer',
            'partner_name' => 'nullable|string|max:100',

            // 현장 정보
            'site_id' => 'nullable|integer',
            'site_name' => 'nullable|string|max:200',

            // 검토 일정
            'request_date' => 'nullable|date',
            'review_date' => 'nullable|date',
            'completion_date' => 'nullable|date|after_or_equal:request_date',

            // 검토자 정보
            'review_company' => 'nullable|string|max:100',
            'reviewer_name' => 'nullable|string|max:50',

            // 상태 정보
            'status' => [
                'nullable',
                Rule::in([StructureReview::STATUS_PENDING, StructureReview::STATUS_COMPLETED]),
            ],

            // 기타
            'file_url' => 'nullable|string|max:500',
            'remarks' => 'nullable|string',
            'is_active' => 'nullable|boolean',
        ];
    }

    public function messages(): array
    {
        return [
            'review_number.max' => __('validation.max.string', ['attribute' => '검토번호', 'max' => 50]),
            'completion_date.after_or_equal' => __('validation.after_or_equal', ['attribute' => '완료일', 'date' => '의뢰일']),
        ];
    }
}
