Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Laravel中找不到ID错误的可排队实体应用程序\设置_Laravel_Queue - Fatal编程技术网

在Laravel中找不到ID错误的可排队实体应用程序\设置

在Laravel中找不到ID错误的可排队实体应用程序\设置,laravel,queue,Laravel,Queue,我正在尝试使用队列在laravel 5.1中发送电子邮件。在终端上运行队列侦听命令时 php artisan queue:listen [Illuminate\Contracts\Queue\EntityNotFoundException] Queueable entity [App\Setting] not found for ID []. 在终端上显示以下错误 php artisan queue:listen [Illuminate\Contracts\Queue\EntityNo

我正在尝试使用
队列
laravel 5.1
中发送电子邮件。在终端上运行队列侦听命令时

php artisan queue:listen
[Illuminate\Contracts\Queue\EntityNotFoundException]  
Queueable entity [App\Setting] not found for ID [].
在终端上显示以下错误

php artisan queue:listen
[Illuminate\Contracts\Queue\EntityNotFoundException]  
Queueable entity [App\Setting] not found for ID [].
未处理
作业
表的值。有什么想法吗


如何处理我的队列?

我知道这个问题已经问了几个月了,但我想在遇到同样的错误消息时添加一个观察结果。这是由于EventListener(本例中异步的ShouldQueue接口)无法正确解析从属变量(超出范围或未包含在通过EventListener的句柄(Event$Event)方法传递的事件对象的范围内)

对我来说,当我将代码放入EventListener中的_构造块时,会触发此错误:

    public function __construct(Event $event)
    {
        $localProperty = $event->property

        Mail::queue(etc...);
    }

    public function handle()
    {
        // Yeah I left this blank... whoops
    }
相反,EventListener的handle()方法接受一个事件接口,调用时处理队列中的作业:

如果:

    public function __construct(Object $ticket, AnotherObject $user)
    {
        $this->ticket   =   $ticket;
        $this->user     =   $user;
    }
事件侦听器

    class SomeEventListener implements ShouldQueue
    {
        use InteractsWithQueue;
        use SerializesModels;

        public function __construct()
        {
            // Leave me blank!
        }

        public function handle(Event $event)
        {
            $someArray = [
                'ticket' = $event->ticket,
                'user'   = $event->user,
            ];

            Mail::queue('some.view', $someArray, function($email) use ($someArray) {
                // Do your code here
            });
        }

    }

虽然有点晚了,但我希望这对某人有所帮助。队列类似于事件(除了作业是队列背后的主要驱动力外),因此大部分都应该是相关的。

结果表明,这是因为队列中添加了一个模型,该模型后来被删除