W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
另外, dispatchAfterResponse
方法會延遲發(fā)送任務,直到將響應發(fā)送到用戶的瀏覽器之后。這仍然允許用戶開始使用應用程序,即使隊列任務仍然在執(zhí)行。這通常只適用于需要 1 秒鐘的任務,比如發(fā)送電子郵件:
use App\Jobs\SendNotification;
SendNotification::dispatchAfterResponse();
你可以 dispatch
一個閉包,并將 afterResponse
方法鏈到幫助程序上,在響應發(fā)送到瀏覽器后執(zhí)行閉包:
use App\Mail\WelcomeMessage;
use Illuminate\Support\Facades\Mail;
dispatch(function () {
Mail::to('taylor@laravel.com')->send(new WelcomeMessage);
})->afterResponse();
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: