A queued job serialises its arguments, so a job dispatched with a customer object writes that customer’s name, email and address into the queue store — where it sits for as long as the backend keeps it.
// the whole model goes into the payload
dispatch(new SendReceipt($customer, $order));
// an id does not
dispatch(new SendReceipt($customer->id, $order->id));
// Laravel serialises models by key automatically with this trait,
// which is the same idea and easy to forget to add:
class SendReceipt implements ShouldQueue
{
use SerializesModels;
}
Passing identifiers rather than objects also fixes a correctness problem — a job that runs ten minutes later should act on the current state of the record, not a snapshot from when it was queued. Failed jobs are the worse case, because they persist indefinitely in a table nobody prunes, so the personal data outlives the job by years. A retention rule on the failed jobs table is a two-line addition that most systems do not have.