<?php

declare(strict_types=1);

namespace App\Listeners;

use App\Events\ServiceProvisioned;
use App\Notifications\ServiceProvisionedNotification;
use Illuminate\Support\Facades\Log;

class HandleServiceProvisioned
{
    public function handle(ServiceProvisioned $event): void
    {
        Log::info("Service provisioned for user #{$event->user->id}", [
            'service_id' => $event->service->id,
            'service_type' => $event->service->service_type,
            'hostname' => $event->service->hostname,
        ]);

        $event->user->notify(new ServiceProvisionedNotification($event->service));
    }
}
