31 lines
642 B
PHP
31 lines
642 B
PHP
<?php
|
|
|
|
namespace App\Events;
|
|
|
|
use Illuminate\Broadcasting\Channel;
|
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
|
|
class WeatherBroadcast implements ShouldBroadcastNow
|
|
{
|
|
use Dispatchable, InteractsWithSockets;
|
|
|
|
public function __construct(public array $data) {}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [new Channel('fox')];
|
|
}
|
|
|
|
public function broadcastAs(): string
|
|
{
|
|
return 'stats.weather';
|
|
}
|
|
|
|
public function broadcastWith(): array
|
|
{
|
|
return $this->data;
|
|
}
|
|
}
|