<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\View;
use App\Models\Member;
use App\Models\Submission;
use App\Models\Package;
use App\Models\Report;

class ViewServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // This makes these variables available in all views that include layouts.app
        View::composer('layouts.app', function ($view) {
            $sidebarBadges = [
                'newSubmissions' => Submission::where('status', 'pending')->count(),
                'approvedMembers' => Member::where('status', 'approved')->count(),
                'binCount' => Submission::where('status', 'rejected')->count(),
                'activePackages' => Package::count(),
                'reportCount' => Report::count(),
            ];
            $view->with('sidebarBadges', $sidebarBadges);

            // in ViewServiceProvider@boot
View::composer('*', function ($view) {
    $view->with('totalMembers', \App\Models\Member::count());
});

        });
    }

    public function register()
    {
        //
    }
}
