From d59ec2548a9bb03658ae6a075b36847aa0c045df Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 5 Dec 2023 15:19:54 +0100 Subject: [PATCH] wip --- app/Events/TestEvent.php | 4 +++- app/Http/Livewire/Dashboard.php | 17 +++++++++++------ routes/web.php | 10 +++++----- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/Events/TestEvent.php b/app/Events/TestEvent.php index 0b94c3f28..2a4c138f6 100644 --- a/app/Events/TestEvent.php +++ b/app/Events/TestEvent.php @@ -13,14 +13,16 @@ class TestEvent implements ShouldBroadcast { use Dispatchable, InteractsWithSockets, SerializesModels; + public $teamId; public function __construct() { + $this->teamId = auth()->user()->currentTeam()->id; } public function broadcastOn(): array { return [ - new Channel('public'), + new PrivateChannel("custom.{$this->teamId}"), ]; } } diff --git a/app/Http/Livewire/Dashboard.php b/app/Http/Livewire/Dashboard.php index 3eb9ccccc..5056c989e 100644 --- a/app/Http/Livewire/Dashboard.php +++ b/app/Http/Livewire/Dashboard.php @@ -10,12 +10,17 @@ class Dashboard extends Component { public $projects = []; public $servers = []; - protected $listeners = ['echo:public,TestEvent' => 'notifyNewOrder']; - - public function notifyNewOrder() - { - $this->emit('success', 'New order received!'); - } + // public function getListeners() + // { + // $teamId = auth()->user()->currentTeam()->id; + // return [ + // "echo-private:custom.{$teamId},TestEvent" => 'notifyNewOrder', + // ]; + // } + // public function notifyNewOrder() + // { + // $this->emit('success', 'New order received!'); + // } public function mount() { $this->servers = Server::ownedByCurrentTeam()->get(); diff --git a/routes/web.php b/routes/web.php index e44e9964c..422fd5f0d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -38,12 +38,12 @@ use Laravel\Fortify\Contracts\FailedPasswordResetLinkRequestResponse; use Laravel\Fortify\Contracts\SuccessfulPasswordResetLinkRequestResponse; use Laravel\Fortify\Fortify; -Route::get('/fire', function () { - event(new \App\Events\TestEvent()); - return 'fired'; -}); -if (isDev()) { +if (isDev()) { + Route::get('/fire', function () { + event(new \App\Events\TestEvent()); + return 'fired'; + }); Route::get('/dev/compose', Compose::class)->name('dev.compose'); } Route::post('/forgot-password', function (Request $request) {