<?php

namespace App\Providers;

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

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

    public function boot(): void
    {
        View::composer('layouts.partials.topbar', function ($view) {
            if (auth()->check()) {
                $view->with('unread_notifications', Notification::where('user_id', auth()->id())->whereNull('read_at')->count());
            }
        });
    }
}
