<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Artesaos\SEOTools\Facades\SEOTools;
use Artesaos\SEOTools\Facades\SEOMeta;
use App\Models\CarouselImage;
class HomeController extends Controller
{
  public function index(Request $request){
    $title = isset(settings()->site_title) ? settings()->site_title : '';
    $description = isset(settings()->site_meta_description) ? settings()->site_meta_description : '';
    $imgURL = isset(settings()->site_logo) ? asset('/images/site/'.settings()->site_logo) : '';
    $keywords = isset(settings()->site_meta_keywords) ? settings()->site_meta_keywords : '';
    $currentUrl = url()->current();
    /** Meta SEO*/
    SEOTools::setTitle($title, false);
    SEOTools::setDescription($description);
    SEOMeta::setKeywords($keywords);
    /** Open Graph*/
    SEOTools::opengraph()->setUrl($currentUrl);
    SEOTools::opengraph()->addImage($imgURL);
    SEOTools::opengraph()->addProperty('type', 'articles');

    SEOTools::twitter()->addImage($imgURL);
    SEOTools::twitter()->setUrl($currentUrl);
    SEOTools::twitter()->setSite('@larablog');
    $images = CarouselImage::all();
    $data =[
        'pageTitle'=>$title,
        'images' =>  $images
    ];
    return view('front.pages.home', $data);
  }
  
}
