<?php

namespace App\Events;

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

class AppointmentCreated implements ShouldBroadcastNow
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $patient_id;
    public $appointment_id;
    public $meeting_id;
    public $call_type;
    /**
     * Create a new event instance.
     */
    public function __construct($patient_id, $appointment_id, $meeting_id, $call_type)
    {
        $this->patient_id = $patient_id;
        $this->appointment_id = $appointment_id;
        $this->meeting_id = $meeting_id;
        $this->call_type = $call_type;
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return array<int, \Illuminate\Broadcasting\Channel>
     */
    public function broadcastOn(): array
    {
        return [
            new PrivateChannel('patient-' . $this->patient_id),
        ];
    }

    /**
     * Get the data to broadcast.
     *
     * @return array<string, mixed>
     */
    public function broadcastWith(): array
    {
        return [
            'patient_id' => $this->patient_id,
            'appointment_id' => $this->appointment_id,
            'meeting_id' => $this->meeting_id,
            'call_type' => $this->call_type
        ];
    }
}
