matchish / laravel-scout-elasticsearch

Search among multiple models with ElasticSearch and Laravel Scout
MIT License
705 stars 113 forks source link

[BUG] Error: The script tried to call a method on an incomplete object. #203

Open dragonfire1119 opened 2 years ago

dragonfire1119 commented 2 years ago

Describe the bug When eager loading is enabled, scout:import fails on the horizon queue.

To Reproduce Steps to reproduce the behavior:

  1. Run a command 'php artisan scout:import App\Post'
  2. Error: The script tried to call a method on an incomplete object. Please ensure that the class definition "App\Services\WithPostsScope" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide an autoloader to load the class definition in /app/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:163

Expected behavior To use horizon queue to import my model.

Additional context Only appears to fail when queuing the import.

Version This package version: 5.0.2

Laravel Framework 9.10.1 Laravel Scout 9.4.7 Laravel Horizon 5.9