<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use App\Models\Category;

class ViewServiceProvider extends ServiceProvider
{
    /**
     * Register services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap services.
     */
    public function boot(): void
    {
        // Share categories with all views
        View::composer(['components.shop-layout', 'layouts.shop'], function ($view) {
            $categories = Category::active()->orderBy('sort_order')->get();
            $view->with('headerCategories', $categories);
        });
    }
}
