<?php

namespace App\Providers;

use App\Repositories\AddressRepository;
use App\Repositories\AddressRepositoryInterface;
use App\Repositories\ContactRepository;
use App\Repositories\ContactRepositoryInterface;
use App\Repositories\OrderRepository;
use App\Repositories\OrderRepositoryInterface;
use App\Repositories\PackRepository;
use App\Repositories\PackRepositoryInterface;
use App\Repositories\PriceListRepository;
use App\Repositories\PriceListRepositoryInterface;
use App\Repositories\ProducerRepository;
use App\Repositories\ProducerRepositoryInterface;
use App\Repositories\ProductRepository;
use App\Repositories\ProductRepositoryInterface;
use App\Repositories\ProfitCenterRepository;
use App\Repositories\ProfitCenterRepositoryInterface;
use App\Repositories\SupplierRepository;
use App\Repositories\SupplierRepositoryInterface;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;

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

        if ($this->app->environment('local', 'testing')) {
            $this->app->register(\Laravel\Dusk\DuskServiceProvider::class);
        }

        $this->app->bind(AddressRepositoryInterface::class, AddressRepository::class);
        $this->app->bind(ContactRepositoryInterface::class, ContactRepository::class);
        $this->app->bind(OrderRepositoryInterface::class, OrderRepository::class);
        $this->app->bind(PackRepositoryInterface::class, PackRepository::class);
        $this->app->bind(PriceListRepositoryInterface::class, PriceListRepository::class);
        $this->app->bind(ProducerRepositoryInterface::class, ProducerRepository::class);
        $this->app->bind(ProductRepositoryInterface::class, ProductRepository::class);
        $this->app->bind(ProfitCenterRepositoryInterface::class, ProfitCenterRepository::class);
        $this->app->bind(SupplierRepositoryInterface::class, SupplierRepository::class);
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        URL::forceScheme('https');

        \Illuminate\Database\Schema\Blueprint::macro('userIdFields', function () {
            $this->unsignedInteger('created_by')->nullable();
            $this->unsignedInteger('updated_by')->nullable();
            $this->unsignedInteger('deleted_by')->nullable();
        });

        \Livewire\Livewire::component('app.filament.pages.price-list-processor', \App\Filament\Pages\PriceListProcessor::class);
        \Livewire\Livewire::component('app.filament.pages.calendar-test', \App\Filament\Pages\CalendarTest::class);
        \Livewire\Livewire::component('app.filament.widgets.delivery-calendar-widget', \App\Filament\Widgets\DeliveryCalendarWidget::class);
/*
        \Livewire\Livewire::component('filament.livewire.notifications', \Filament\Livewire\Notifications::class);
        \Livewire\Livewire::component('filament.livewire.database-notifications', \Filament\Livewire\DatabaseNotifications::class);
        \Livewire\Livewire::component('filament.livewire.sidebar', \Filament\Livewire\Sidebar::class);
        \Livewire\Livewire::component('filament.livewire.topbar', \Filament\Livewire\Topbar::class);
        \Livewire\Livewire::component('filament.livewire.global-search', \Filament\Livewire\GlobalSearch::class);
*/
    }
}
