I cannot change the channel name in the event class. Every change I make in the class is not loaded. (I am using laravel-websockets)
/app/Events/BroadcastingModelEvent
class BroadcastingModelEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct($message)
{
$this->message = $message;
}
public function broadcastOn()
{
return new Channel('test');
}
}
/routes/web.php
:
Route::get('test', function () {
event(new App\Events\BroadcastingModelEvent('Test'));
return "Event has been sent!";
});
VueComponent
Echo.channel('test')
.listen('BroadcastingModelEvent', (e) => {
console.log(e);
});
So this code works, I receive the event in the console.log everything is ok.
But if I change return new Channel('something');
and Echo.channel('something')
it stops working.
I tried php artisan route:clear
, php artisan cache:clear
, php artisan event:clear
and nothing works.I stopped the php artisan websockets:serve
process and restarted it. That class only works with the 'test' name I first gave and nothing else.
I cannot figure out where is it caching the class because any change I make in BroadcastingModelEvent
is not reflected.
For anyone facing this issue, you need to restart the queue worker process when you edit the events.