<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use Illuminate\Support\Facades\Auth;

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

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        View::composer('layouts.navbar', function ($view) {
            if (session()->has('api_token')) {
                $notifications = [
                    ['text' => 'Kegiatan sudah ditinjau super admin', 'is_read' => false],
                    ['text' => 'Aktivitas berhasil disimpan', 'is_read' => true],
                    ['text' => 'Perubahan data tersimpan', 'is_read' => true],
                ];
                $unreadCount = collect($notifications)->where('is_read', false)->count();
                $view->with(compact('notifications', 'unreadCount'));
            }
        });
    }
}