<?php

namespace App\Http\Controllers\Web;

use App\Address;
use App\Http\Controllers\Controller;
use App\Http\Requests\Web\VisitorMessageRequest;
use App\Page;
use App\Slider;
use App\VisitorMessage;
use Illuminate\Http\JsonResponse;

class VisitorMessageController extends Controller
{

    private $view = 'web.contacts.';


    public function index()
    {
        $page = Slider::withDescription(null, [8]);
        $title = $page->title;
        $pageImage = asset($page->image);
        $sliders = Slider::withDescription('contact', [], [8]);
        $addresses = Address::withDescription();

        return view( $this->view.'index', get_defined_vars());
    }

    public function store(VisitorMessageRequest $request) :JsonResponse
    {
        VisitorMessage::create($request->all());
        return response()->json(['message' => __('visitorMessages.message_success')]);
    }
}
