<?php

namespace App\Http\Controllers;

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

class ContactController extends Controller
{
    public function create()
    {
        return view('pages.contact');
    }

    public function store(Request $request)
    {
        $validated = $request->validate([
            'name'    => ['required', 'string', 'max:120'],
            'email'   => ['required', 'email', 'max:160'],
            'message' => ['required', 'string', 'max:3000'],
        ]);

        Contact::create($validated);

        return redirect()
            ->route('contact.create')
            ->with('success', 'Your message has been sent. We will get back to you soon!');
    }
}
