<?php

namespace Koneko\SatCatalogs\Providers;

use Illuminate\Support\ServiceProvider;
use Koneko\SatCatalogs\Console\Commands\GenerateCsvFromXlsx;
use Koneko\SatCatalogs\Console\Commands\ImportCsvToDatabase;

class SatCatalogsServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // Register the module's routes
        $this->loadRoutesFrom(__DIR__.'/../routes/admin.php');

        // Register the migrations
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');

        // Registrar comandos de consola
        if ($this->app->runningInConsole()) {
            $this->commands([
                GenerateCsvFromXlsx::class,
                ImportCsvToDatabase::class,
            ]);
        }

        // Publicar los archivos necesarios
        $this->publishes([
            __DIR__.'/../database/seeders/SatCatalogsSeeder.php' => database_path('seeders/SatCatalogsSeeder.php'),
            __DIR__.'/../database/seeders/sat_cache' => database_path('seeders/sat_cache'),
        ], 'sat-catalogs-seeders');
    }
}
