<?php

namespace App\Providers;

use App\Services\DummyDataService;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;

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

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        if ($this->app->environment('production')) {
            URL::forceScheme('https');
        }

        View::composer('*', function ($view) {
            $notifikasi = collect(DummyDataService::getNotifikasi());
            $unreadNotificationsCount = $notifikasi->where('read', false)->count();

            $view->with(compact('notifikasi', 'unreadNotificationsCount'));
        });
    }
}
