<?php

namespace App\Http\Controllers;

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

class ContactPageController extends Controller
{
    public function index() {}

    public function store(Request $request)
    {
        $data = $request->validate([
            'name' => ['required', 'string', 'max:255'],
            'phone' => ['required', 'numeric'],
            'company_name' => ['nullable', 'string', 'max:255'],
            'email' => ['nullable', 'string', 'email', 'max:255'],
            'message' => ['required', 'string'],
        ]);

        ContactUs::create($data);

        return back()
            ->with('message', 'Habarlaşanyňyz üçin sag boluň! Gysga wagtda siziň bilen habarlaşarys.')
            ->withFragment('#contact-us-form');
    }
}
