mirror of
https://github.com/crivion/laranode.git
synced 2026-05-07 22:20:44 +08:00
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use App\Services\Dashboard\SystemStatsService;
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Broadcasting\PresenceChannel;
|
|
use Illuminate\Broadcasting\PrivateChannel;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBeUnique;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class SystemStatsEvent implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
|
|
/**
|
|
* Create a new event instance.
|
|
*/
|
|
public function __construct(public array $stats = [])
|
|
{
|
|
$this->stats = (new SystemStatsService)->getAllStats();
|
|
}
|
|
|
|
/**
|
|
* Get the channels the event should broadcast on.
|
|
*
|
|
* @return array<int, \Illuminate\Broadcasting\Channel>
|
|
*/
|
|
public function broadcastOn(): array
|
|
{
|
|
return [
|
|
new PrivateChannel('systemstats'),
|
|
];
|
|
}
|
|
|
|
public function broadcastWith()
|
|
{
|
|
return $this->stats;
|
|
}
|
|
}
|