36 lines
833 B
PHP
36 lines
833 B
PHP
<?php
|
||
|
||
namespace App\Events;
|
||
|
||
use Illuminate\Broadcasting\Channel;
|
||
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
||
|
||
class TaskUpdated implements ShouldBroadcastNow
|
||
{
|
||
public function __construct(
|
||
public string $taskId,
|
||
public int $userId,
|
||
public array $payload, // genau das JSON, das du in Redis speicherst
|
||
) {}
|
||
|
||
public function broadcastOn(): Channel
|
||
{
|
||
// Public channel – simpel. (Wenn du willst, nutze Private Channels.)
|
||
return new Channel('system.tasks');
|
||
}
|
||
|
||
public function broadcastAs(): string
|
||
{
|
||
return 'task.updated';
|
||
}
|
||
|
||
public function broadcastWith(): array
|
||
{
|
||
return [
|
||
'taskId' => $this->taskId,
|
||
'userId' => $this->userId,
|
||
'payload' => $this->payload,
|
||
];
|
||
}
|
||
}
|