Created
October 26, 2020 12:47
-
-
Save crystaldaking/561cb33824f76c1f9e429ae17a835d3c to your computer and use it in GitHub Desktop.
batch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use App\Jobs\ProcessPodcast; | |
use App\Podcast; | |
use Illuminate\Bus\Batch; | |
use Illuminate\Support\Facades\Bus; | |
use Throwable; | |
$batch = Bus::batch([ | |
new ProcessPodcast(Podcast::find(1)), | |
new ProcessPodcast(Podcast::find(2)), | |
new ProcessPodcast(Podcast::find(3)), | |
new ProcessPodcast(Podcast::find(4)), | |
new ProcessPodcast(Podcast::find(5)), | |
])->then(function (Batch $batch) { | |
// All jobs completed successfully... | |
})->catch(function (Batch $batch, Throwable $e) { | |
// First batch job failure detected... | |
})->finally(function (Batch $batch) { | |
// The batch has finished executing... | |
})->dispatch(); | |
return $batch->id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment