use App\Jobs\ImportCsv;
use Illuminate\Bus\Batch;
use Illuminate\Support\Facades\Bus;
use Throwable;
$batch = Bus::batch([newImportCsv(1,100),newImportCsv(101,200),newImportCsv(201,300),newImportCsv(301,400),newImportCsv(401,500),])->then(function(Batch $batch){// 所有任务均已成功完成...})->catch(function(Batch $batch, Throwable $e){// 检测到第一批任务失败...})->finally(function(Batch $batch){// 批处理已完成执行...})->dispatch();return $batch->id;
推荐文章: