<?php

namespace App\Http\Controllers;

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

class PagesController extends Controller
{
    private function getContactInfo()
    {
        $appSettings = \App\Models\AppSetting::getAllCached();
        return [
            'contactEmail'    => $appSettings['contact_email'] ?? null,
            'contactPhone'    => $appSettings['contact_phone'] ?? null,
            'contactAddress'  => $appSettings['contact_address'] ?? null,
            'contactFacebook' => $appSettings['contact_facebook'] ?? null,
            'contactTwitter'  => $appSettings['contact_twitter'] ?? null,
            'contactInstagram'=> $appSettings['contact_instagram'] ?? null,
            'contactYoutube'  => $appSettings['contact_youtube'] ?? null,
            'contactLinkedin' => $appSettings['contact_linkedin'] ?? null,
        ];
    }

    public function about()
    {
        $page = Page::where('slug', 'about')->first();
        $contactInfo = $this->getContactInfo();
        return view('pages.about', array_merge(compact('page'), $contactInfo));
    }

    public function privacy()
    {
        $page = Page::where('slug', 'privacy')->first();
        return view('pages.privacy', compact('page'));
    }

    public function faq()
    {
        $page = Page::where('slug', 'faq')->first();
        return view('pages.faq', compact('page'));
    }
}
