<?php

namespace Kylin\GameData;

use Illuminate\Support\ServiceProvider;
use Kylin\GameData\Services\GameDataSyncService;
use Kylin\GameData\Services\GameDataService;

class GameDataServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->mergeConfigFrom(
            __DIR__ . '/../config/kylin-game-data.php', 'kylin-game-data'
        );

        $this->app->singleton(GameDataSyncService::class);
        $this->app->singleton(GameDataService::class);
        $this->app->singleton('kylin-game-data', GameDataService::class);
    }

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

        $this->publishes([
            __DIR__ . '/../database/migrations/' => database_path('migrations'),
        ], 'kylin-game-data-migrations');

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

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