<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Mail\ContactMail;
use Illuminate\Support\Facades\Mail;
use App\Mail\ContactConfirmationMail;

class ContactController extends Controller
{
    public function send(Request $request)
    {
        $validated = $request->validate([
            'name' => 'required|string|max:255',
            'phone' => 'required|string|max:20',
            'email' => 'required|email',
            'subject' => 'required|string',
            'message' => 'required|string',
        ]);

        Mail::to('info@brighteagles.co.za')->send(new ContactMail($validated));
        Mail::to($validated['email'])->send(new ContactConfirmationMail($validated));

        return redirect()->back()->with('success', 'Your message has been sent successfully!');
    }
}
