<?php

namespace App\Events;

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

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

    /**
     * True/false to indicate update status
     */
    public $update;

    /**
     * The booking ID this event is for
     */
    public $bookingId;

    /**
     * @param bool $update
     * @param int $bookingId
     */
    public function __construct($update, $bookingId)
    {
        $this->update = $update;        // true or false
        $this->bookingId = $bookingId;  // unique booking identifier
    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return \Illuminate\Broadcasting\Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('admin.pdf.1688.processing.' . $this->bookingId);
    }
}
