<?php

namespace App\Providers;

use App\Models\Dossier;
use App\Models\Notification;
use Carbon\Carbon;
use Illuminate\Support\ServiceProvider;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\Facades\Auth;

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

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

        // dd(Auth::user());
    //     if (Auth::check()){

    //     if (Auth::user()){
    //         $notifications = Notification::with('user')->whereDate('created_at', '<', Carbon::today()->toDateString())->latest()->get();

    //     }
    //     else {
    //         $dossiers = Dossier::whereHas('step', function ($query) {
    //             $query->where('user_id', auth()->user()->id);
    //         })->get();
    //         $array = [];
    //         foreach ($dossiers as $dossier) {
    //             array_push($array, $dossier->id);
    //         }
    //         $notifications = Notification::whereIn('dossier_id', $array)->whereDate('created_at', '<', Carbon::today()->toDateString())->latest()->get();
    //     }
    //     view()->share('notifications', $notifications);

    // }
    //     view()->share('notifications', $notifications);
        Paginator::useBootstrap();
    }
}
