<?php

namespace Kylin\Guardian;

use Illuminate\Support\ServiceProvider;
use Kylin\Guardian\Services\GuardianNotifyService;
use Kylin\Guardian\Services\GuardianService;

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

        $this->app->singleton(GuardianService::class);
        $this->app->singleton(GuardianNotifyService::class);
        $this->app->singleton('kylin-guardian', GuardianService::class);
    }

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

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

        $this->publishes([
            __DIR__ . '/../config/kylin-guardian.php' => config_path('kylin-guardian.php'),
        ], 'kylin-guardian-config');

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