You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Event class is not correctly serializing the event payload. The seat object's ID is being serialized as a string instead of a JSON object.
I am using Laravel Reverb 1.0 to broadcast the event trough WebSocket and receive the message on differente clients (Chrome and Postman).
Event class:
<?php
namespace App\Events;
use App\Http\Resources\SeatResource;
use App\Models\Seat;
use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class SeatUpdatedEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public function __construct(
public Seat $seat
) {
}
/**
* Get the channels the event should broadcast on.
*
* @return array<int, \Illuminate\Broadcasting\Channel>
*/
public function broadcastOn(): array
{
return [
new Channel('show-'.$this->seat->show_id),
];
}
public function broadcastWith(): array
{
return ['id' => $this->seat->id];
}
}
Laravel Version
11
PHP Version
8.3
Database Driver & Version
MySQL 8.0 for Windows 11 (x64)
Description
The Event class is not correctly serializing the event payload. The
seat
object's ID is being serialized as a string instead of a JSON object.I am using Laravel Reverb 1.0 to broadcast the event trough WebSocket and receive the message on differente clients (Chrome and Postman).
Event class:
JSON response:
Steps To Reproduce
The text was updated successfully, but these errors were encountered: