<?php

namespace App\Providers;

use App\Models\Client;
use App\Models\ExtraSettings;
use App\Models\Screen;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

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

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        View::composer('*', function ($view) {
            if (Auth::check()) {
                $company_id = Auth::user()->company_id;
                $screen_settings = Screen::where('company_id', $company_id)
                    ->first();
                View::share('screen_settings', $screen_settings);
                $extra_settings = ExtraSettings::where('company_id', $company_id)
                    ->first();
                View::share('extra', $extra_settings);

                // if (Auth::guard('client-web')->check()) {
                //     $user = Auth::user();
                //     $package = $user->company->subscription->type->package;
                //     View::share('user', $user);
                //     View::share('package', $package);
                // }
            }
        });
    }
}
