<?php

namespace App\Providers;

use App\Models\Gallery;
use App\Models\Setting;
use App\Repositories\BlogRepository;
use App\Repositories\BlogRepositoryEloquent;
use App\Repositories\CartRepository;
use App\Repositories\CartRepositoryEloquent;
use App\Repositories\CategoryRepository;
use App\Repositories\CategoryRepositoryEloquent;
use App\Repositories\CMSPagesRepositoryEloquent;
use App\Repositories\ColourRepository;
use App\Repositories\ColourRepositoryEloquent;
use App\Repositories\FaqRepository;
use App\Repositories\FaqRepositoryEloquent;
use App\Repositories\GalleryRepositoryEloquent;
use App\Repositories\HomePageSliderRepository;
use App\Repositories\HomePageSliderRepositoryEloquent;
use App\Repositories\ProductRepository;
use App\Repositories\ProductRepositoryEloquent;
use App\Repositories\StripeRepository;
use App\Repositories\StripeRepositoryEloquent;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind(CMSPagesRepositoryEloquent::class);
        $this->app->bind(GalleryRepositoryEloquent::class);
        $this->app->bind(HomePageSliderRepository::class, HomePageSliderRepositoryEloquent::class);
        $this->app->bind(BlogRepository::class, BlogRepositoryEloquent::class);
        $this->app->bind(FaqRepository::class, FaqRepositoryEloquent::class);
        $this->app->bind(ProductRepository::class, ProductRepositoryEloquent::class);
        $this->app->bind(ColourRepository::class, ColourRepositoryEloquent::class);
        $this->app->bind(CategoryRepository::class, CategoryRepositoryEloquent::class);
        $this->app->bind(StripeRepository::class, StripeRepositoryEloquent::class);
        $this->app->bind(CartRepository::class, CartRepositoryEloquent::class);
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        try {
            $setting = Setting::first();
            $gallories = Gallery::all();

            View::share([
                'setting' => $setting,
                'gallories' => $gallories,
            ]);
        } catch (\Exception $e) {

            View::share([
                'setting' => null,
                'gallories' => null,

            ]);
        }
    }
}
