<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Artesaos\SEOTools\Facades\SEOTools;
use Artesaos\SEOTools\Facades\SEOMeta;
use App\Models\Album;

class PhotoGalleryController extends Controller
{
    public function index()
    {
        $title = 'Photo Gallery | Polytechnic College of Davao del Sur';
        $description = 'Discover memorable moments at Polytechnic College of Davao del Sur through our photo gallery – showcasing student life, events, and activities.';

        SEOTools::setTitle($title, false);
        SEOTools::setDescription($description);
        SEOTools::opengraph()->setUrl(url()->current());

        $albums = Album::latest()->get();

        return view('front.pages.photo-gallery.photo-gallery', [
            'pageTitle' => $title,
            'albums' => $albums,
        ]);
    }

    public function photoGalleryAlbum(Album $album)
    {
        $title = $album->title . 'Photo Gallery | Polytechnic College of Davao del Sur';
        SEOTools::setTitle($title,false);
        SEOTools::setDescription('View photos from the album: ' . $album->title);
        SEOTools::opengraph()->setUrl(url()->current());

        $photos = $album->photos()->latest()->get(); // Assumes Album has a `photos()` relationship

        return view('front.pages.photo-gallery.album-view', [
            'album' => $album,
            'photos' => $photos,
            'pageTitle' => $title
        ]);
    }
    
}
