<?php

declare(strict_types=1);

namespace Kylin\Parking;

use Illuminate\Support\ServiceProvider;
use Kylin\Parking\Services\ParkingService;

/**
 * 智能停车系统服务提供者
 *
 * 提供停车场管理、车位管理、停车记录、月卡管理等功能。
 *
 * 法律合规：
 *  - 《价格法》：明码标价，计费规则公开透明
 *  - 《个人信息保护法》：车牌号加密存储
 *  - 《网络安全法》：操作审计日志
 *  - GA/T 1028.3-2022：车牌识别置信度 >= 0.85
 */
class ParkingServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(
            __DIR__ . '/../config/kylin-parking.php',
            'kylin-parking'
        );

        $this->app->singleton(ParkingService::class);
        $this->app->singleton('kylin-parking', ParkingService::class);
    }

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

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

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