Hydration issues on serialized Model with relations #57241
Unanswered
liviuroman
asked this question in
Q&A
Replies: 1 comment
-
Dispatching a model will only dispatch it's primary key and the model will be fetched in the job by primary key. You accessing the relations in the job will generate a new query for them. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a problem that I can't figure out, and I'm not sure if it's a bug or if I don't understand how relationship model hydration works when they running from queue.
Some code as example:
app\Models\Author:
app\Console\Commands\SendAuthorProcessingJob:
app\Jobs\ProcessAuthorJob:
From what I have observed, in the first scenario, the "primaryGenreBooks" relationship does not work because $this in the relationship function is null.
I'm not really looking for a workaround, but for an explanation on what I'm missing and why is working like that.
Beta Was this translation helpful? Give feedback.
All reactions