feat: Realtime for Votes + Deadlines

This commit is contained in:
2024-03-24 01:36:16 +01:00
parent b1cb25c823
commit 5c0dab3448
9 changed files with 133 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace App\Events\Vote;
use App\Models\Vote;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class VoteCreated implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*/
public function __construct(
public Vote $vote
)
{
//
}
public function broadcastAs(): string
{
return 'VoteCreated';
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('Vote'),
];
}
}