laravel-json-api icon indicating copy to clipboard operation
laravel-json-api copied to clipboard

BroadcastsData::serializeData() does not appear to process $includePaths parameter correctly.

Open k8n opened this issue 1 year ago • 0 comments

https://github.com/cloudcreativity/laravel-json-api/blob/86e9dbad5df8f077f75f7803fa70e6800d1f113e/src/Broadcasting/BroadcastsData.php#L58

BroadcastsData::serializeData() appears to call Encoder::serializeData(). Encoder::serializeData() does not appear to take a second parameter. And thus no matter if includes are specified or not, the data going down the broadcast wire will have no includes. Below is what BroadcastsData::serializeData() should probably look like.

// BroadcastsData.php
// ...

    protected function serializeData($data, $includePaths = null, array $fieldsets = null)
    {
        $params = new QueryParameters($includePaths ? (array) $includePaths : null, $fieldsets);

        return $this->broadcastEncoder()->withEncodingParameters($params)->serializeData($data);
    }

k8n avatar Oct 17 '24 13:10 k8n