Laravel - Broadcasting - Broadcast Data

When an event is broadcast, all of its public properties are automatically serialized and broadcast as the event's payload, allowing you to access any of its public data from your JavaScript application. So, for example, if your event has a single public $user property that contains an Eloquent model, the event's broadcast payload would be:

        "user": {
            "id": 1,
            "name": "Patrick Stewart"

However, if you wish to have more fine-grained control over your broadcast payload, you may add a broadcastWith method to your event. This method should return the array of data that you wish to broadcast as the event payload:

     * Get the data to broadcast.
     * @return array
    public function broadcastWith()
        return ['id' => $this->user->id];