<?php

namespace App\Providers;

use App\Models\Setting;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Throwable;

class AppServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        //
    }

    public function boot(): void
    {
        // Share branding (logo + favicon) ke semua view.
        // Aman saat tabel belum ada (mis. sebelum migrate) — fallback ke null.
        View::composer('*', function ($view) {
            try {
                $view->with('brandLogoUrl', Setting::logoUrl());
                $view->with('brandFaviconUrl', Setting::faviconUrl());
            } catch (Throwable $e) {
                $view->with('brandLogoUrl', null);
                $view->with('brandFaviconUrl', null);
            }
        });
    }
}
