<?php

namespace App\Modules\PLATFORM\Settings\Providers;

use App\Core\Modules\ModuleServiceProvider;

class CoreModuleServiceProvider extends ModuleServiceProvider
{
    /**
     * Module name
     */
    protected string $moduleName = 'Settings';

    /**
     * Module slug
     */
    protected string $moduleSlug = 'settings';

    /**
     * Module path
     */
    protected string $modulePath;

    public function __construct($app)
    {
        parent::__construct($app);
        $this->modulePath = __DIR__ . '/..';
    }

    /**
     * Register module services
     */
    public function register(): void
    {
        parent::register();
    }

    /**
     * Bootstrap module services
     */
    public function boot(): void
    {
        // Core always loads migrations and views
        if ($this->app->runningInConsole()) {
            $this->registerMigrations();
        }

        $this->registerViews();

        // Core routes always load (branch selector must be accessible)
        $webRoutePath = $this->modulePath . '/Routes/web.php';
        if (file_exists($webRoutePath)) {
            \Illuminate\Support\Facades\Route::middleware('web')
                ->group($webRoutePath);
        }
    }
}
