<?php

namespace App\Http\Controllers;

use App\Livewire\Admin\OfficeDepartment;
use Illuminate\Http\Request;

use Artesaos\SEOTools\Facades\SEOTools;
use Artesaos\SEOTools\Facades\SEOMeta;
use App\Models\Offices;
use App\Models\OfficesDepartment;

class OfficesController extends Controller
{

    protected $offices;

    public function __construct()
    {
        // This runs once when the controller is instantiated
        $this->offices = Offices::pluck('description', 'id')->toArray();
    }
    private function getDepartmentDataByOfficeId(int $officeId)
{
    return OfficesDepartment::where('office_department_id', $officeId)->first();
}
    protected function setSEO($title)
    {
        $description = settings()->site_meta_description ?? '';
        $imgURL = settings()->site_logo ? asset('/images/site/' . settings()->site_logo) : '';
        $keywords = settings()->site_meta_keywords ?? '';
        $currentUrl = url()->current();

        SEOTools::setTitle($title, false);
        SEOTools::setDescription($description);
        SEOMeta::setKeywords($keywords);

        SEOTools::opengraph()->setUrl($currentUrl)->addImage($imgURL)->addProperty('type', 'articles');
        SEOTools::twitter()->addImage($imgURL)->setUrl($currentUrl)->setSite('@larablog');
    }
    public function associateVicePresidentForAcademicAffairs()
    {
        $officeId = 1;
        $title = $this->offices[$officeId] ?? 'Associate Vice President For Academic Affairs Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.associate-vice-president-for-academic-affairs', $data);
    }
    public function financeDepartment() {
        $officeId = 2;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.finance-department', $data);
    }
    public function humanResourcesDepartment() {
        $officeId = 3;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.human-resources-department', $data);
    }
    public function learningResourcesAndInformationCenter() {
        $officeId = 4;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.learning-resources-and-information-center', $data);
    }
    public function officeOfStudentAffairs() {
        $officeId = 5;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.office-of-student-affairs', $data);
    }
    public function presidentsOffice() {
        $officeId = 6;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.presidents-office', $data);
    }
    public function criminologyDepartment() {
        $officeId = 8;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.criminology-department', $data);
    }
    public function hospitalityManagementDepartment() {
        $officeId = 9;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.hospitality-management-department', $data);
    }
    public function informationTechnologyDepartment() {
        $officeId = 10;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.information-technology-department', $data);
    }
    public function nursingDepartment() {
        $officeId = 11;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.nursing-department', $data);
    }
    public function researchAndDevelopment() {
        $officeId = 12;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.research-and-development', $data);
    }
    public function tesdaDepartment() {
        $officeId = 14;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.tesda-department', $data);
    }
    public function registrarsOffice() {
        $officeId = 7;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.registrars-office', $data);
    }
    public function radiologicTechnologyDepartment(){
        $officeId = 13;
        $title = $this->offices[$officeId] ?? 'Finance Department'; // Adjust ID accordingly
        $pageTitle = $title . ' | Polytechnic College of Davao del Sur';

        $this->setSEO($pageTitle);
        $data = [
            'pageTitle' => $pageTitle,
            'officeDepartment'=>$this->offices[$officeId],
            'officeAdmin' => $this->getDepartmentDataByOfficeId($officeId)
        ];

        return view('front.pages.offices.radiologic-technology-department', $data);
    }
}
