listening on event does not call method

What I am trying to do: I have to call method with an event. What I did: I followed instructions https://livewire.laravel.com/docs/events#private--presence-channels how to define listeners and method to execute on event. Laravel Echo, and server side pusher is defined correctly My issue/the error: The notifyAlert method does not call on event. Laravel Echo in console shows the channel see scrnshot Code:
<?php namespace App\Filament\Resources\CutterResource\Pages;

use App\Filament\Resources\CutterResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
use Livewire\Attributes\On;

class ListCutters extends ListRecords
{
protected static string $resource = CutterResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}

public function getListeners()
{
return [
"echo-private:cut-plan-movements,cut-plan-inserted" => 'notifyAlert',
];
}

public function notifyAlert()
{
dd($this);
}
}
<?php namespace App\Filament\Resources\CutterResource\Pages;

use App\Filament\Resources\CutterResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\ListRecords;
use Livewire\Attributes\On;

class ListCutters extends ListRecords
{
protected static string $resource = CutterResource::class;

protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}

public function getListeners()
{
return [
"echo-private:cut-plan-movements,cut-plan-inserted" => 'notifyAlert',
];
}

public function notifyAlert()
{
dd($this);
}
}
<?php namespace App\Events;

use App\Broadcasting\CutPlanMovements;
use App\Models\CutPlan;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class CutPlanInsertedEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public CutPlan $cutPlan;

public function __construct(CutPlan $cutPlan)
{
$this->cutPlan = $cutPlan;
}

public function broadcastAs() : string
{
return 'cut-plan-inserted';
}

public function broadcastOn(): Channel
{
return new PrivateChannel('cut-plan-movements');
}
}
<?php namespace App\Events;

use App\Broadcasting\CutPlanMovements;
use App\Models\CutPlan;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class CutPlanInsertedEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public CutPlan $cutPlan;

public function __construct(CutPlan $cutPlan)
{
$this->cutPlan = $cutPlan;
}

public function broadcastAs() : string
{
return 'cut-plan-inserted';
}

public function broadcastOn(): Channel
{
return new PrivateChannel('cut-plan-movements');
}
}
Laravel
Events | Laravel
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server