请问 Laravel 中间件如何推送队列?

2016-04-14 10:05:31 +08:00
 Liang

微信认证写在中间件里,当中有个SaveUserAvatar的操作,是下载用户头像的。打算把这个操作放在队列中执行,但在中间件中如何推送队列?按文档的方法$this->dispatch(new SaveUserAvatar($user))会报错,提示信息为Fatal error: Call to undefined method App\Http\Middleware\Authenticate::dispatch()

Laravel 5.1

2124 次点击
所在节点    PHP
3 条回复
jhdxr
2016-04-15 00:49:12 +08:00
RTFM ,然后可以节省彼此的时间
> Of course, sometimes you may wish to dispatch a job from somewhere in your application besides a route or controller. For that reason, you can include the `DispatchesJobs` trait on any of the classes in your application to gain access to its various dispatch methods.
Liang
2016-04-15 07:08:14 +08:00
@jhdxr 谢谢提点!已解决。
CodingWorker
2016-05-04 14:51:55 +08:00
查缺补漏,感谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/270939

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX