Files

35 lines
802 B
PHP
Raw Permalink Normal View History

2023-12-05 11:17:52 +01: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 TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
2024-06-10 20:43:34 +00:00
2025-05-05 09:04:09 +02:00
public ?int $teamId = null;
2024-06-10 20:43:34 +00:00
2023-12-05 11:17:52 +01:00
public function __construct()
{
2025-05-05 09:04:09 +02:00
if (auth()->check() && auth()->user()->currentTeam()) {
$this->teamId = auth()->user()->currentTeam()->id;
}
2023-12-05 11:17:52 +01:00
}
public function broadcastOn(): array
{
2025-05-05 09:04:09 +02:00
if (is_null($this->teamId)) {
return [];
}
2023-12-05 11:17:52 +01:00
return [
2023-12-11 10:23:10 +01:00
new PrivateChannel("team.{$this->teamId}"),
2023-12-05 11:17:52 +01:00
];
}
}