<?php

namespace App\Http\Controllers;

use App\Models\CarouselSlide;
use App\Models\Category;
use App\Models\Collection;
use App\Models\Product;
use App\Settings\GeneralSettings;
use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function __invoke(GeneralSettings $settings)
    {
        $slides = CarouselSlide::query()->where('is_active', true)->orderBy('order')->get();
        $collections = Collection::with(['collectionItems' => function ($query) {
            $query->where('is_active', true)->orderBy('order');
        }])->where('is_active', true)->orderBy('order')->get();
        $categories = Category::query()->orderBy('order')->get();
        $products = Product::query()->with('category')->where('is_active', true)->get();

        return view('home', compact('slides', 'collections', 'categories', 'products', 'settings'));
    }
}
