Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mikefolsom's avatar

Queued mails throwing Query Builder exceptions

I’m running into a strange issue with mailables which are sent to a Redis queue. The jobs are failing with the exception message `BadMethodCallException: Method Illuminate\Database\Query\Builder::getDetailSummary does not exist. in /home/forge/.../vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:28.

I can open up tinker, grab a registration from the database and send it manually via the same mailable (e.g., Mail::send())with no problems. I’m scratching my head and probably missing something obvious. Running Laravel 5.7.20.

email blade template:

...
## Details
{!! $registration->getDetailSummary() !!}
...

EventRegistration model:

    public function getDetailSummary(): string
    {
        return $this->getGolfDetailSummary();
    }

    public function getGolfDetailSummary($separator = '<br>'): string
    {
        return collect($this->details)
            ->reject(function ($val) {
                return ! $val;
            })
            ->map(function ($val, $key) {
                return sprintf('%s: %s',
                    str_humanize($key),
                    $key == 'start_time'
                        ? make_date($val, 'g:i a')
                        : $val
                );
            })
            ->implode($separator);
    }

Don’t worry too much about the methods—they just format some output that is stored as JSON.

0 likes
2 replies
D9705996's avatar
D9705996
Best Answer
Level 51

As a first step I would restart the queue worker to make sure it is something odd with cached code in the worker threads

mikefolsom's avatar

@d9705996 Yep, that was it. That was a new-ish method on the model and apparently, the model definition had been cached. Thanks!

Please or to participate in this conversation.