laravel Jobs 队列处理

phpartisanmake:jobSendEmail--queued
生成后在App\Jobs
namespaceApp\Jobs;
useApp\User;
useApp\Jobs\Job;
useIlluminate\Contracts\Mail\Mailer;
useIlluminate\Queue\SerializesModels;
useIlluminate\Queue\InteractsWithQueue;
useIlluminate\Contracts\Bus\SelfHandling;
useIlluminate\Contracts\Queue\ShouldQueue;
classSendEmailextendsJobimplementsSelfHandling,ShouldQueue
{
useInteractsWithQueue,SerializesModels;
protected$user;
/**
*Createanewjobinstance.
*
*@returnvoid
*/
publicfunction__construct(User$user)
{
$this->user=$user;
}
/**
*Executethejob.
*
*@returnvoid
*/
publicfunctionhandle(Mailer$mailer,$email)
{
$mailer->send('emails.reminder',['user'=>$this->user],function($m){
$m->to($email,'zan')->subject('发送成功');
});
}
}
在控制器里这么用;
$email="onm@163.com";
$job=(newSendEmail($user,$email))->delay(260);
$this->dispatch($job);
在这里传email到handle方法里面;
可handle方法里根本获取不到$email这个变量
Jobs队列处理如何传入更多数据呢在控制器里传入
求大神指导一下呀
繁星点点滴滴
浏览 1070回答 2
2回答

慕桂英546537

php$mailer->send('emails.reminder',['user'=>$this->user],function($m)use($email){$m->to($email,'zan')->subject('发送成功');});

扬帆大鱼

改下job
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript