2023-12-08 11:12:44 +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;
|
2025-05-20 11:23:09 +00:00
|
|
|
use Illuminate\Support\Facades\Auth;
|
2023-12-08 11:12:44 +00:00
|
|
|
|
|
|
|
|
class ServiceStatusChanged implements ShouldBroadcast
|
|
|
|
|
{
|
|
|
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2025-05-20 11:23:09 +00:00
|
|
|
public function __construct(
|
|
|
|
|
public ?int $teamId = null
|
|
|
|
|
) {
|
|
|
|
|
if (is_null($this->teamId) && Auth::check() && Auth::user()->currentTeam()) {
|
|
|
|
|
$this->teamId = Auth::user()->currentTeam()->id;
|
2023-12-08 12:07:42 +00:00
|
|
|
}
|
2023-12-08 11:12:44 +00:00
|
|
|
}
|
|
|
|
|
|
2025-05-19 19:50:32 +00:00
|
|
|
public function broadcastOn(): array
|
2023-12-08 11:12:44 +00:00
|
|
|
{
|
2025-05-19 19:50:32 +00:00
|
|
|
if (is_null($this->teamId)) {
|
2025-04-30 16:30:43 +00:00
|
|
|
return [];
|
2024-07-02 14:12:04 +00:00
|
|
|
}
|
|
|
|
|
|
2025-04-30 16:30:43 +00:00
|
|
|
return [
|
2025-05-19 19:50:32 +00:00
|
|
|
new PrivateChannel("team.{$this->teamId}"),
|
2025-04-30 16:30:43 +00:00
|
|
|
];
|
2023-12-08 11:12:44 +00:00
|
|
|
}
|
|
|
|
|
}
|