<?php

namespace Functional\Exercises\Providers;

use Functional\Exercises\Console\Commands\ImportExercisesCommand;
use Functional\Exercises\Console\Commands\ImportTranslationsCommand;
use Functional\Exercises\Database\Seeders\ExercisesSeeder;
use Xefi\LaravelOSDD\LayerServiceProvider;

class ExercisesServiceProvider extends LayerServiceProvider
{
    public function boot(): void
    {
        if ($this->app->runningInConsole()) {
            $this->loadMigrationsFrom(__DIR__ . '/../../database/migrations');
            $this->loadSeeders([ExercisesSeeder::class]);
            $this->commands([ImportExercisesCommand::class, ImportTranslationsCommand::class]);
        }

        $this->withRouting(
            web: __DIR__ . '/../../routes/web.php',
            api: __DIR__ . '/../../routes/api.php',
            commands: __DIR__ . '/../../routes/console.php',
            channels: __DIR__ . '/../../routes/channels.php',
        );
        $this->loadSeeders([\Functional\Exercises\Database\Seeders\ExercisesSeeder::class]);
    }

    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__ . '/../../config/exercises.php', 'exercises');
        $this->mergeConfigFrom(__DIR__ . '/../../config/exercise_i18n.php', 'exercise_i18n');
    }
}
