Liang
V2EX  ›  PHP

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

  •  
  •   Liang · Apr 14, 2016 · 2936 views
    This topic created in 3687 days ago, the information mentioned may be changed or developed.

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

    Laravel 5.1

    3 replies    2016-05-04 14:51:55 +08:00
    jhdxr
        1
    jhdxr  
       Apr 15, 2016   ❤️ 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
       Apr 15, 2016
    @jhdxr 谢谢提点!已解决。
    CodingWorker
        3
    CodingWorker  
       May 4, 2016
    查缺补漏,感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1423 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 17:10 · PVG 01:10 · LAX 10:10 · JFK 13:10
    ♥ Do have faith in what you're doing.