share-lt/app/Events/TestEvent.php

31 lines
681 B
PHP
Raw Permalink Normal View History

<?php
namespace App\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class TestEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(
public string $message = 'Test message from Laravel'
) {}
public function broadcastOn(): array
{
return [
new Channel('test-channel'),
];
}
public function broadcastAs(): string
{
return 'test.message';
}
}