Skip to content

Fix payload serialization #115

Open
Open
@tonysm

Description

@tonysm

When we send a broadcasting job to be processed in background, because the job payload can be anything (whatever you want to pass to the view), we don't really use Laravel's ModelIdentifier class (here).

The current implementation works, but the jobs are unnecessarily big, since the object is serialized using PHP's normal serialization. This also has the side-effect of the model having all the attributes it had during from the moment the model was serialized. For instance, if we wanted to return the HTML slightly modified as an HTTP response Turbo Stream for the user that created the resource, we'd use the $model->wasRecentlyCreated, but if we wanted the broadcasted Turbo Stream to not be modified, we would have to override the data passed to the view, because since the model was serialized, it will also have the $model->wasRecentlyCreated set to true when the broadcast job is processed.

I think this could be solved by walking through the data array and finding out the eloquent models and either converting them to either use ModelIdentifier or maybe using globalid-laravel (here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions