<?php

namespace App\Controllers;

use App\Models\SettingModel;

class Home extends BaseController
{
    public function index()
    {
        $settings = (new SettingModel())->values([
            "call_phone_display" => "+91 98765 43210",
            "call_phone_href" => "+919876543210",
            "whatsapp_number" => "919876543210",
            "social_instagram" => "",
            "social_behance" => "",
            "social_facebook" => "",
            "social_linkedin" => "",
            "social_youtube" => "",
            "social_pinterest" => "",
        ]);

        return view("home", [
            "phoneDisplay" => $settings["call_phone_display"],
            "phoneHref" => $settings["call_phone_href"],
            "whatsappNumber" => $settings["whatsapp_number"],
            "socialLinks" => $this->socialLinks($settings),
        ]);
    }

    public function landing1()
    {
        return view("landing_1");
    }
    public function landing2()
    {
        return view("landing_2");
    }
    public function landing3()
    {
        return view("landing_3");
    }
    public function landing4()
    {
        return view("landing_4");
    }
    public function landing5()
    {
        return view("landing_5");
    }
    public function landing6()
    {
        return view("landing_6");
    }

    public function logoDesignIndia()
    {
        $settings = (new SettingModel())->values([
            "call_phone_display" => "+91 98765 43210",
            "call_phone_href" => "+919876543210",
            "whatsapp_number" => "919876543210",
        ]);

        return view("google_ads_logo_design", [
            "phoneDisplay" => $settings["call_phone_display"],
            "phoneHref" => $settings["call_phone_href"],
            "whatsappNumber" => $settings["whatsapp_number"],
        ]);
    }

    public function logoRedesignIndia()
    {
        $settings = (new SettingModel())->values([
            "call_phone_display" => "+91 98765 43210",
            "call_phone_href" => "+919876543210",
            "whatsapp_number" => "919876543210",
        ]);

        return view("google_ads_logo_redesign", [
            "phoneDisplay" => $settings["call_phone_display"],
            "phoneHref" => $settings["call_phone_href"],
            "whatsappNumber" => $settings["whatsapp_number"],
        ]);
    }

    public function logoRedesignScorecard()
    {
        $settings = (new SettingModel())->values([
            "call_phone_display" => "+91 98765 43210",
            "call_phone_href" => "+919876543210",
            "whatsapp_number" => "919876543210",
            "social_instagram" => "",
            "social_behance" => "",
            "social_facebook" => "",
            "social_linkedin" => "",
            "social_youtube" => "",
            "social_pinterest" => "",
        ]);

        return view("logo_redesign_scorecard", [
            "phoneDisplay" => $settings["call_phone_display"],
            "phoneHref" => $settings["call_phone_href"],
            "whatsappNumber" => $settings["whatsapp_number"],
            "socialLinks" => $this->socialLinks($settings),
        ]);
    }

    private function socialLinks(array $settings): array
    {
        $links = [];
        foreach (
            [
                "Instagram" => "social_instagram",
                "Behance" => "social_behance",
                "Facebook" => "social_facebook",
                "LinkedIn" => "social_linkedin",
                "YouTube" => "social_youtube",
                "Pinterest" => "social_pinterest",
            ]
            as $label => $key
        ) {
            if (!empty($settings[$key])) {
                $links[$label] = $settings[$key];
            }
        }
        return $links;
    }
}
