<?php

namespace App\Events;

use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class CalendarUpdated implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public function __construct(
        public readonly string $userId
    ) {}

    public function broadcastOn(): array
    {
        return [
            new PrivateChannel("calendar.{$this->userId}"),
        ];
    }

    public function broadcastAs(): string
    {
        return 'calendar.updated';
    }
}
