From e4a58212724498c37b83f12c827540067165fc95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Wed, 18 Sep 2024 18:10:47 +0200 Subject: [PATCH] define channel for accessing invoice presence --- routes/channels.php | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/routes/channels.php b/routes/channels.php index 9d8de62648d0..583b8f986814 100644 --- a/routes/channels.php +++ b/routes/channels.php @@ -11,6 +11,8 @@ | */ +use App\Models\User; + // Broadcast::channel('App.User.{id}', function ($user, $id) { // nlog($id); @@ -18,6 +20,18 @@ // // return (int) $user->id === (int) $id; // }); -Broadcast::channel('company-{company_key}', function (\App\Models\User $user, string $company_key) { +Broadcast::channel('company-{company_key}', function (User $user, string $company_key) { return $user->company()->company_key === $company_key; -}); \ No newline at end of file +}); + +Broadcast::channel('company-${company.company_key}.{roomId}', function (User $user, int $roomId) { + if ($user->canJoinRoom($roomId)) { + return ['id' => $user->id, 'name' => $user->name]; + } +}); + +Broadcast::channel('company-{company_key}.invoices.{invoice_id}', function (User $user, string $company_key, string $invoice_id) { + // @todo + + return true; +});