mailwolt/app/Events/TaskUpdated.php

36 lines
833 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?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,
];
}
}