<?php

namespace App\Http\Requests\NotificationSetting;

use App\Models\NotificationSetting;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

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

    public function rules(): array
    {
        return [
            'settings' => ['required', 'array', 'min:1'],
            'settings.*.notification_type' => ['required', 'string', Rule::in(NotificationSetting::getAllTypes())],
            'settings.*.push_enabled' => ['nullable', 'boolean'],
            'settings.*.email_enabled' => ['nullable', 'boolean'],
            'settings.*.sms_enabled' => ['nullable', 'boolean'],
            'settings.*.in_app_enabled' => ['nullable', 'boolean'],
            'settings.*.kakao_enabled' => ['nullable', 'boolean'],
            'settings.*.settings' => ['nullable', 'array'],
        ];
    }

    public function messages(): array
    {
        return [
            'settings.required' => __('validation.required', ['attribute' => '설정']),
            'settings.array' => __('validation.array', ['attribute' => '설정']),
            'settings.*.notification_type.required' => __('validation.required', ['attribute' => '알림 유형']),
            'settings.*.notification_type.in' => __('validation.in', ['attribute' => '알림 유형']),
        ];
    }
}
