<?php

namespace App\Apps\Versionmgr;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;

class ServiceProvider extends BaseServiceProvider
{
    public function boot(): void
    {
        $this->registerRoutes();
        $this->loadViews();
    }

    protected function registerRoutes(): void
    {
        $routeFile = base_path('app/Apps/Versionmgr/Routes/web.php');
        if (!file_exists($routeFile)) {
            return;
        }
        Route::prefix('admin/versionmgr')
            ->namespace('App\Apps\Versionmgr\Controllers')
            ->middleware(['web', 'auth:admin'])
            ->group($routeFile);
    }

    protected function loadViews(): void
    {
        $viewsPath = base_path('app/Apps/Versionmgr/Views');
        if (!is_dir($viewsPath)) {
            return;
        }
        $this->loadViewsFrom($viewsPath, 'versionmgr');
    }
}
