阅读(392) (5)

Laravel 8 取消批处理

2021-07-06 09:25:05 更新

有时候你可能需要取消指定的批处理的执行,可以通过 IlluminateBusBatch 实例调用 cancel 方法来完成:

/**
 * 执行任务
 *
 * @return void
 */
public function handle()
{
    if ($this->user->exceedsImportLimit()) {
        return $this->batch()->cancel();
    }

    if ($this->batch()->cancelled()) {
        return;
    }
}