<?php

namespace App\Providers;

use App\Models\Domain;
use App\Observers\DomainObserver;
use Filament\Support\Facades\FilamentAsset;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\File;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Domain::observe(DomainObserver::class);

        $versionFile = base_path('VERSION');
        $appVersion = File::exists($versionFile) ? trim(File::get($versionFile)) : null;
        FilamentAsset::appVersion($appVersion ?: null);

        // Note: AuthEventListener is auto-discovered by Laravel 11+
        // Do not manually subscribe - it causes duplicate audit log entries
    }
}
