<?php

namespace Kylin\Ecommerce;

use Illuminate\Support\ServiceProvider;

/**
 * 电商系统服务提供者
 *
 * 提供电商平台基础架构，包括商品管理、订单处理、
 * 购物车、支付集成等核心功能。
 */
class EcommerceServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(
            __DIR__ . '/../config/kylin-ecommerce.php', 'kylin-ecommerce'
        );

        $this->app->singleton('kylin-ecommerce', function () {
            return new EcommerceManager();
        });
    }

    public function boot(): void
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([
                __DIR__ . '/../config/kylin-ecommerce.php' => config_path('kylin-ecommerce.php'),
            ], 'kylin-ecommerce-config');
        }

        $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
        $this->loadRoutesFrom(__DIR__ . '/../routes/api.php');
    }
}
