<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Modules\ModulesProvider as AdminModulesProvider;
use App\Models\Factory as ModelsFactory;

class AppServiceProvider extends ServiceProvider
{
    const ADMIN_MODULES = 'admin_modules';

    const MODELS_FACTORY = 'models-factory';

    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        $this->loadViewsFrom(__DIR__ . '/../../src/views', 'common');
        $this->app->singleton(self::ADMIN_MODULES, function ($app) {
            $provider = new AdminModulesProvider();
            $provider->init();
            return $provider;
        });

        $this->app->singleton(self::MODELS_FACTORY, function ($app) {
            $factory = new ModelsFactory();
            return $factory;
        });
    }
}
