3ffd3fc819
feat: database backup is realtime now
35 lines
906 B
PHP
35 lines
906 B
PHP
<?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 ServiceStatusChanged implements ShouldBroadcast
|
|
{
|
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
|
public $userId;
|
|
public function __construct($userId = null)
|
|
{
|
|
if (is_null($userId)) {
|
|
$userId = auth()->user()->id ?? null;
|
|
}
|
|
if (is_null($userId)) {
|
|
throw new \Exception("User id is null");
|
|
}
|
|
$this->userId = $userId;
|
|
}
|
|
|
|
public function broadcastOn(): array
|
|
{
|
|
return [
|
|
new PrivateChannel("user.{$this->userId}"),
|
|
];
|
|
}
|
|
}
|