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

blueyan's avatar

dataErrorException: Trying to get property of non-object when QUEUE_DRIVER=database

The Queue is running ok when

.env QUEUE_DRIVER=sync

When I change QUEUE_DRIVER=database

and run php artisan queue:work

[https://imgur.com/fSf0WIV ]

I encountered the following error

[2017-10-04 22:02:55] local.ERROR: ErrorException: Trying to get property of non-object in \app\Jobs\ExportReport.php:42
Stack trace:
#0 \app\Jobs\ExportReport.php(42): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', 42, Array)
#1 [internal function]: App\Jobs\ExportReport->handle()

here is ExportReport.php:42

 42       $exportDelete = ExportsQueue::where('usrcreated', Auth::user()->USERKEY)
 43          ->where('jobname', $this->reportrequest)
 44         ->whereDate('dtcreated', DB::raw('CURDATE()'))->first();

Can we use Eloquent in Job Class when QUEUE_DRIVER=database ? It works if QUEUE_DRIVER=sync.

Please help. Thanks.

0 likes
2 replies
goatshark's avatar

@blueyan Did you:

php artisan queue:table

php artisan migrate

...before switching the queue driver to database?

Please or to participate in this conversation.