2024-11-04 13:18:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Events;
|
|
|
|
|
|
2025-01-07 13:52:08 +00:00
|
|
|
use Exception;
|
2024-11-04 13:18:16 +00:00
|
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
|
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
|
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
|
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
|
|
|
|
|
|
class DatabaseProxyStopped implements ShouldBroadcast
|
|
|
|
|
{
|
|
|
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
|
|
|
|
|
|
public $teamId;
|
|
|
|
|
|
|
|
|
|
public function __construct($teamId = null)
|
|
|
|
|
{
|
|
|
|
|
if (is_null($teamId)) {
|
2024-11-25 12:17:09 +00:00
|
|
|
$teamId = Auth::user()?->currentTeam()?->id ?? null;
|
2024-11-04 13:18:16 +00:00
|
|
|
}
|
|
|
|
|
if (is_null($teamId)) {
|
2025-01-07 13:52:08 +00:00
|
|
|
throw new Exception('Team id is null');
|
2024-11-04 13:18:16 +00:00
|
|
|
}
|
|
|
|
|
$this->teamId = $teamId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function broadcastOn(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
new PrivateChannel("team.{$this->teamId}"),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|