<?php

namespace App\Http\Controllers\Web;

use App\Http\Controllers\Controller;
use App\Http\Requests\Web\VisitorMessageRequest;
use App\VisitorMessage;
use Illuminate\Http\JsonResponse;
use Illuminate\View\View;

class VisitorMessageController extends Controller
{
    /**
     * Show the Contact US details.
     * @return View
     */
    public function index()
    {
        $title = __('visitorMessages.head');
        return view( 'web.contact_us', get_defined_vars());
    }

    /**
     * Store a Message and send it to the admin in storage.
     *
     * @param VisitorMessageRequest $request
     * @return JsonResponse
     */
    public function store(VisitorMessageRequest $request) :JsonResponse
    {
        VisitorMessage::create($request->all());
        return response()->json(['message' => __('visitorMessages.message_success')]);
    }
}
