feat: api api api api api api

This commit is contained in:
Andras Bacsai
2024-07-02 16:12:04 +02:00
parent 3c13f1ff61
commit 4459c9f73d
13 changed files with 636 additions and 85 deletions

View File

@@ -12,7 +12,7 @@ class DatabaseStatusChanged implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $userId;
public ?string $userId = null;
public function __construct($userId = null)
{
@@ -20,15 +20,19 @@ class DatabaseStatusChanged implements ShouldBroadcast
$userId = auth()->user()->id ?? null;
}
if (is_null($userId)) {
throw new \RuntimeException('User id is null');
return false;
}
$this->userId = $userId;
}
public function broadcastOn(): array
public function broadcastOn(): ?array
{
return [
new PrivateChannel("user.{$this->userId}"),
];
if ($this->userId) {
return [
new PrivateChannel("user.{$this->userId}"),
];
}
return null;
}
}