<?php

namespace Modules\Admin\Providers;

use Nwidart\Modules\Support\ModuleServiceProvider;

class AdminServiceProvider extends ModuleServiceProvider
{
    protected string $name = 'Admin';

    protected string $nameLower = 'admin';

    protected array $providers = [
        EventServiceProvider::class,
        RouteServiceProvider::class,
    ];

    public function boot(): void
    {
        parent::boot();

        if ($this->app->runningInConsole()) {
            $this->commands([
                \Modules\Admin\Console\CreateAdminUser::class,
            ]);
        }
    }

    public function register(): void
    {
        parent::register();
        $this->registerBindings();
    }

    private function registerBindings(): void
    {
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\UserRepositoryInterface::class,
            \Modules\Admin\Repositories\UserRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\ProductRepositoryInterface::class,
            \Modules\Admin\Repositories\ProductRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\CategoryRepositoryInterface::class,
            \Modules\Admin\Repositories\CategoryRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\OrderRepositoryInterface::class,
            \Modules\Admin\Repositories\OrderRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\CartItemRepositoryInterface::class,
            \Modules\Admin\Repositories\CartItemRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\BasketItemRepositoryInterface::class,
            \Modules\Admin\Repositories\BasketItemRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\PaymentMethodRepositoryInterface::class,
            \Modules\Admin\Repositories\PaymentMethodRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\SaveTheFoodProductRepositoryInterface::class,
            \Modules\Admin\Repositories\SaveTheFoodProductRepository::class
        );
        $this->app->bind(
            \Modules\Admin\Repositories\Interfaces\WeeklySpecialRepositoryInterface::class,
            \Modules\Admin\Repositories\WeeklySpecialRepository::class
        );
    }
}
