<?php

namespace App\Support;

use App\Models\Room;

class EventsSourceLink
{
    public static function eventAdminUrl(Room $room): ?string
    {
        $source = (array) ($room->source ?? []);

        if (($source['app'] ?? '') !== 'events') {
            return null;
        }

        $eventId = (int) ($source['event_id'] ?? 0);
        if ($eventId <= 0) {
            return null;
        }

        $base = rtrim((string) config('meet.events_app_url', 'https://events.ladill.com'), '/');

        return $base.'/events/'.$eventId.'/attendees';
    }
}
