Skip to content

Stop Passing Eloquent Models Everywhere

Quick Tips•
December 1, 2026

SendWelcomeEmail takes a User and uses SerializesModels. The queue stores only the model's class and id, and the worker loads the row again with a fresh query when the job runs (SerializesAndRestoresModelIdentifiers::restoreModel()). If the user renamed themselves in between, the email uses the new name. If the row is gone, the job fails with ModelNotFoundException. And $this->user->profile runs one more query inside the worker unless the profile was already loaded at dispatch.

Don't do this:

PHP
<?php declare(strict_types=1); namespace App\Notifications; use App\Mail\WelcomeMail; use App\Models\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\SerializesModels; use Illuminate\Support\Facades\Mail; final class SendWelcomeEmail implements ShouldQueue { use Dispatchable; use Queueable; use SerializesModels; public function __construct( private User $user, ) {} public function handle(): void { // The worker reloads $this->user by id, and $this->user->profile // is a second query unless it was loaded before dispatch. Mail::to($this->user->email)->send( new WelcomeMail($this->user->name, $this->user->profile->locale), ); } }

Do this instead:

PHP
<?php declare(strict_types=1); namespace App\Notifications; use App\Mail\WelcomeMail; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Mail\Mailer; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; final readonly class WelcomeRecipient { public function __construct( public string $email, public string $name, public string $locale, ) {} } final class SendWelcomeEmail implements ShouldQueue { use Dispatchable; use Queueable; public function __construct( private WelcomeRecipient $recipient, ) {} public function handle(Mailer $mailer): void { $mailer->to($this->recipient->email)->send( new WelcomeMail($this->recipient->name, $this->recipient->locale), ); } }

The dispatching code builds WelcomeRecipient from the user it already has, and the job declares exactly what it needs. The payload is three strings, so the worker runs no query and finds no row missing. Renaming users.name changes the one place that builds the DTO, not the job. The data is a snapshot taken at dispatch. If the email must reflect the latest row, pass the id and load the row inside the job on purpose.