Files
laranode/app/Events/TopStatsEvent.php
Alex Crivion bb75e3a42b initial commit
2025-01-31 14:04:22 +02:00

42 lines
1012 B
PHP
Executable File

<?php
namespace App\Events;
use App\Services\TopCommandService;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBeUnique;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class TopStatsEvent implements ShouldBroadcast, ShouldBeUnique
{
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*/
public function __construct(public array $stats = [])
{
$this->stats = (new TopCommandService)->run();
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new PrivateChannel('topstats'),
];
}
public function broadcastWith(): array
{
return $this->stats;
}
}