You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
<?php |
|
|
|
namespace App\Events; |
|
|
|
use Illuminate\Broadcasting\Channel; |
|
use Illuminate\Broadcasting\InteractsWithSockets; |
|
use Illuminate\Broadcasting\PresenceChannel; |
|
use Illuminate\Broadcasting\PrivateChannel; |
|
use Illuminate\Contracts\Broadcasting\ShouldBroadcast; |
|
use Illuminate\Foundation\Events\Dispatchable; |
|
use Illuminate\Queue\SerializesModels; |
|
|
|
|
|
class ExampleEvent implements ShouldBroadcast |
|
{ |
|
use Dispatchable, InteractsWithSockets, SerializesModels; |
|
|
|
/** |
|
* Create a new event instance. |
|
*/ |
|
public $message; |
|
public $token; |
|
public function __construct($message, $token = null) |
|
{ |
|
$this->message = $message; |
|
$this->token = $token ?? null; |
|
} |
|
|
|
/** |
|
* Get the channels the event should broadcast on. |
|
* |
|
* @return array<int, \Illuminate\Broadcasting\Channel> |
|
*/ |
|
public function broadcastOn() |
|
{ |
|
// return new Channel('test-channel'); |
|
if ($this->token) { |
|
return new PrivateChannel('test-private.' . $this->token); |
|
} |
|
return [ |
|
// 'test-event', |
|
new Channel('test-channel'), |
|
new PrivateChannel('test-private'), |
|
]; |
|
} |
|
// public function broadcastWith() |
|
// { |
|
// return [ |
|
// 'data' => 'key' |
|
// ]; |
|
// } |
|
}
|
|
|