2023-12-11 12:43:16 +00:00
|
|
|
<?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 ApplicationStatusChanged implements ShouldBroadcast
|
|
|
|
{
|
|
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-11 12:43:16 +00:00
|
|
|
public $teamId;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-11 12:43:16 +00:00
|
|
|
public function __construct($teamId = null)
|
|
|
|
{
|
|
|
|
if (is_null($teamId)) {
|
|
|
|
$teamId = auth()->user()->currentTeam()->id ?? null;
|
|
|
|
}
|
|
|
|
if (is_null($teamId)) {
|
2024-06-10 20:43:34 +00:00
|
|
|
throw new \Exception('Team id is null');
|
2023-12-11 12:43:16 +00:00
|
|
|
}
|
|
|
|
$this->teamId = $teamId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function broadcastOn(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
new PrivateChannel("team.{$this->teamId}"),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|