adrema/app/Lib/Events/ClientMessage.php

55 lines
1.0 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Lib\Events;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcastNow;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class ClientMessage implements ShouldBroadcastNow
{
use Dispatchable;
use InteractsWithSockets;
use SerializesModels;
public bool $reload = false;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct(public string $message)
{
}
public static function make(string $message): self
{
2023-08-15 00:17:17 +02:00
return new self($message);
}
public function shouldReload(): self
{
$this->reload = true;
return $this;
}
public function dispatch(): void
{
event($this);
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel
*/
public function broadcastOn()
{
return new Channel('jobs');
}
}