<?php

namespace App\Http\Requests\NotificationSetting;

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

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

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

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