<?php

namespace App\Http\Controllers;

use App\Models\Inquiry;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;

class InquiryController extends Controller
{
    public function store(Request $request): RedirectResponse
    {
        $data = $request->validate([
            'type' => ['required', 'in:corporate,speaking,coaching,support'],
            'name' => ['required', 'string', 'max:120'],
            'email' => ['required', 'email', 'max:190'],
            'phone' => ['nullable', 'string', 'max:30'],
            'organization' => ['nullable', 'string', 'max:160'],
            'event_name' => ['nullable', 'string', 'max:160'],
            'event_date' => ['nullable', 'date'],
            'audience_profile' => ['nullable', 'string', 'max:80'],
            'staff_size' => ['nullable', 'integer', 'min:1', 'max:100000'],
            'event_format' => ['nullable', 'string', 'max:80'],
            'delivery_mode' => ['nullable', 'string', 'max:40'],
            'venue' => ['nullable', 'string', 'max:190'],
            'session_duration' => ['nullable', 'string', 'max:80'],
            'topics' => ['nullable', 'array'],
            'topics.*' => ['string', 'max:80'],
            'message' => ['required', 'string', 'max:5000'],
        ]);

        Inquiry::create($data);

        return back()->with('inquiry_sent', true);
    }
}
