I'm using an event which broadcasts an user object. The user object contains
"id":2,
"name":"Clark",
"surname":"Beer",
"email":"schultz.arthur@example.com",
"role":"user",
"information":{
"user_id":2,
"bio":"Dicta fugit voluptas fugiat doloremque.",
"profile_picture_id":2,
"image":{
"id":2,
"path":"https:\/\/lorempixel.com\/640\/640\/people\/?54438"
}
}
But the problem is, the broadcast sends only the user model without the "information" child object, this is caused by the SerializesModels.
The broadcast works fine when I delete the SerializesModels import, but it would be nice too still use the SerializesModels trait.
Is there a way to include the childobjects while using the SerializesModels trait?
class searchUserEvent implements ShouldBroadcastNow {
use Dispatchable, InteractsWithSockets, SerializesModels;
/**
* Create a new event instance.
*
* @return void
*/
public $users;
public function __construct($users)
{
$this->users = $users;
}
/**
* Get the channels the event should broadcast on.
*
* @return \Illuminate\Broadcasting\Channel|array
*/
public function broadcastOn()
{
return new Channel('searchUser');
}