Skip to content

Commit 1b2d681

Browse files
[8.x] Explain eager/lazy load behavior when serializing models in a queued job (laravel#7653)
* Update queues.md * Update queues.md Co-authored-by: Taylor Otwell <[email protected]>
1 parent 8e10644 commit 1b2d681

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

queues.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ If you would like to take total control over how the container injects dependenc
221221
> {note} Binary data, such as raw image contents, should be passed through the `base64_encode` function before being passed to a queued job. Otherwise, the job may not properly serialize to JSON when being placed on the queue.
222222
223223
<a name="handling-relationships"></a>
224-
#### Handling Relationships
224+
#### Queued Relationships
225225

226226
Because loaded relationships also get serialized, the serialized job string can sometimes become quite large. To prevent relations from being serialized, you can call the `withoutRelations` method on the model when setting a property value. This method will return an instance of the model without its loaded relationships:
227227

@@ -236,6 +236,8 @@ Because loaded relationships also get serialized, the serialized job string can
236236
$this->podcast = $podcast->withoutRelations();
237237
}
238238

239+
Furthermore, when a job is deserialized and model relationships are re-retrieved from the database, they will be retrieved in their entirety. Any previous relationship constraints that were applied before the model was serialized during the job queueing process will not be applied when the job is deserialized. Therefore, if you wish to work with a subset of a given relationship, you should re-constrain that relationship within your queued job.
240+
239241
<a name="unique-jobs"></a>
240242
### Unique Jobs
241243

0 commit comments

Comments
 (0)