<?php

namespace App\Events\Applications;

use App\Models\Applications\Application;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ApplicationStatusChanged {
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public Application $application;
    public string $status;

    public function __construct(Application $application, $status = null) {
        $this->application = $application;
        $this->status = $status ?? $application->status;
    }

    public function broadcastOn(): PrivateChannel {
        return new PrivateChannel('channel-name');
    }
}
