<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\SiteSetting;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

class SupportSettingController extends Controller
{
    public function update(Request $request): RedirectResponse
    {
        $validated = $request->validate([
            'support_email' => ['required', 'email', 'max:255'],
            'support_auto_reply_message' => ['required', 'string', 'max:1000'],
        ]);

        SiteSetting::setValue(SiteSetting::SUPPORT_EMAIL, $validated['support_email']);
        SiteSetting::setValue(SiteSetting::SUPPORT_AUTO_REPLY_MESSAGE, $validated['support_auto_reply_message']);

        return redirect()
            ->route('admin.settings.index')
            ->with('success', 'Support settings updated successfully.');
    }
}
