<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Mail;

class ContactController extends Controller
{
    public function index()
    {
        return view('contact.index');
    }
    
    public function store(Request $request)
    {
        $validated = $request->validate([
            'name' => 'required|string|max:255',
            'email' => 'required|email|max:255',
            'message' => 'required|string|max:5000',
        ]);
        
        // Store contact message as an inquiry (general inquiry, no product)
        \App\Models\Inquiry::create([
            'name' => $validated['name'],
            'email' => $validated['email'],
            'message' => $validated['message'],
            'product_id' => null, // General contact form inquiry
            'status' => 'pending',
        ]);
        
        return response()->json([
            'success' => true,
            'message' => 'Thank you! We\'ll contact you soon.'
        ]);
    }
}
