Laravel 8 取消批處理

2021-07-06 11:33 更新

有時(shí)候你可能需要取消指定的批處理的執(zhí)行,可以通過 Illuminate\Bus\Batch 實(shí)例調(diào)用 cancel 方法來完成:

/**
 * 執(zhí)行任務(wù)
 *
 * @return void
 */
public function handle()
{
    if ($this->user->exceedsImportLimit()) {
        return $this->batch()->cancel();
    }

    if ($this->batch()->cancelled()) {
        return;
    }
} 
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號