不允许序列化Closure

时间:2017-09-07 21:49:09

标签: php laravel laravel-5 closures

我试图在Laravel中重写一些代码以使其成为一项工作,并且我正在做以下事情:

$subscriptions->each(function ($sub) use ($payload) {
            $channel = $this;

            // new code
            dispatch(new SendOnePushNotification($channel, $sub, $payload));

            // old code below
            /*$this->webPush->sendNotification(
                $sub->endpoint,
                $payload,
                $sub->public_key,
                $sub->auth_token
            );*/

        });

造成这种情况的原因是将$ this传递给SendOnePushNotification构造函数。

我的猜测是我可以用某种方式改写这个,但我不确定如何开始。有什么建议吗?

0 个答案:

没有答案