Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Model with binary UUID can't be used in a Laravel Queue payload #22

@rogatty

Description

@rogatty

dispatch(new MyJob(ModelWithBinaryUuid::create())) fails with:

message: "Unable to JSON encode payload. Error code: 5"
exception: "Illuminate\Queue\InvalidPayloadException"
file: "/vendor/laravel/framework/src/Illuminate/Queue/Queue.php"
line: 91

This is a know issue documented in laravel/framework#15235 and laravel/framework#12194. Laravel's Queue uses json_encode() which doesn't call model's toJson() method. Because of that https://github.com/michaeldyrynda/laravel-model-uuid/blob/79b20e5b2d6cae7b64e45858ea9202b7f26975a6/src/GeneratesUuid.php#L167-L175 is not called.

I don't have any good ideas how to solve it without modifying the Laravel's Queue code. Would be nice to add a note to docs about it, so people using this package don't have to do the research I did. My workaround will be to not pass the whole model to the Queue but only the attributes I need.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions