<?php

namespace App\Http\Controllers;

use App\Models\Enquiry;
use Illuminate\Http\Request;

class EnquiryController extends Controller
{
    public function store(Request $request)
    {
        $request->validate([
            'name'  => 'required|string|max:255',
            'email' => 'required|email|max:255',
        ]);

        Enquiry::create([
            'name'         => $request->name,
            'company'      => $request->company,
            'email'        => $request->email,
            'phone'        => $request->phone,
            'enquiry_type' => $request->enquiry_type ?? 'general',
            'product_id'   => $request->product_id ?: null,
            'message'      => $request->message,
            'status'       => 'new',
        ]);

        return back()->with('success', 'Thank you — your enquiry has been received. We will be in touch shortly.');
    }
}
