<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

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

    public function rules(): array
    {
        return [
            'equipment_id' => 'required|exists:equipments,id',
            'repair_date' => 'required|date',
            'repair_type' => 'required|in:internal,external',
            'repair_hours' => 'nullable|numeric|min:0',
            'description' => 'nullable|string',
            'cost' => 'nullable|numeric|min:0',
            'vendor' => 'nullable|string|max:100',
            'repaired_by' => 'nullable|exists:users,id',
            'memo' => 'nullable|string',
        ];
    }

    public function attributes(): array
    {
        return [
            'equipment_id' => '설비',
            'repair_date' => '수리일',
            'repair_type' => '보전구분',
            'repair_hours' => '수리시간',
            'cost' => '수리비용',
        ];
    }

    public function messages(): array
    {
        return [
            'equipment_id.required' => '설비를 선택해주세요.',
            'repair_date.required' => '수리일은 필수입니다.',
            'repair_type.required' => '보전구분을 선택해주세요.',
        ];
    }
}
