V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Liang
V2EX  ›  PHP

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

  •  
  •   Liang · 2016-04-14 10:05:31 +08:00 · 2111 次点击
    这是一个创建于 2927 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    Laravel 5.1

    3 条回复    2016-05-04 14:51:55 +08:00
    jhdxr
        1
    jhdxr  
       2016-04-15 00:49:12 +08:00   ❤️ 1
    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
        2
    Liang  
    OP
       2016-04-15 07:08:14 +08:00
    @jhdxr 谢谢提点!已解决。
    CodingWorker
        3
    CodingWorker  
       2016-05-04 14:51:55 +08:00
    查缺补漏,感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   881 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:00 · PVG 06:00 · LAX 15:00 · JFK 18:00
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.