<?php

namespace App\Http\Controllers\Front;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\ImageAlbum;
use App\Models\GeneralSettings;
use App\Models\Category;
use App\Models\Language;

class GalleryController extends Controller
{
    public function view($x){
        $default_language = session()->has('language')
            ? Language::find(session()->get('language'))
            : Language::where('is_default', 1)->first();

        $gallery = ImageAlbum::findOrFail($x);
        $gs = GeneralSettings::first();
        $categories = Category::where('language_id', $default_language->id)
            ->whereNull('parent_id')
            ->orderBy('id', 'asc')
            ->get();

        return view('frontend.gallery_view', compact('gallery', 'gs', 'categories'));
    }
}
