<?php

namespace Kylin\Region;

use Illuminate\Support\ServiceProvider;
use Kylin\Region\Services\RegionService;

/**
 * 行政区划服务提供者
 *
 * 提供中国省市区街道四级行政区划数据查询。
 * 支持数据导入命令和 API 接口。
 */
class RegionServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(__DIR__ . '/../config/kylin-region.php', 'kylin-region');
        $this->app->singleton(RegionService::class);
        $this->app->singleton('kylin-region', RegionService::class);
    }

    public function boot(): void
    {
        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
        $this->loadRoutesFrom(__DIR__ . '/../routes/api.php');

        if ($this->app->runningInConsole()) {
            $this->commands([
                \Kylin\Region\Commands\RegionImportCommand::class,
            ]);
        }
    }
}
