<?php

namespace App\Providers;

use App\Modules\ModuleRepository;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        $this->app->singleton(ModuleRepository::class, function (Application $app) {
            return new ModuleRepository;
        });
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Model::unguard();
        Model::shouldBeStrict(! app()->isProduction());

        $this->registerModules();

        // logDB();
    }

    /**
     * Register modules
     */
    public function registerModules(): void
    {
        $this->loadMigrationsFrom(modular()->migrationsPaths());
    }
}
