Skip to content

Commit ec5caf5

Browse files
irakliShengeliataylorotwell
authored andcommitted
Redirects to batches page when batch not found (laravel#1383)
* fix: redirects to batches page when batch not found * Update BatchesController.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent ffdb4b8 commit ec5caf5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

resources/js/screens/batches/preview.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
4444
this.$http.get(Horizon.basePath + '/api/batches/' + this.$route.params.batchId)
4545
.then(response => {
46+
if (!response.data.batch) {
47+
this.$router.push({name: 'batches'})
48+
}
49+
4650
this.batch = response.data.batch;
4751
this.failedJobs = response.data.failedJobs;
4852

src/Http/Controllers/BatchesController.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ public function show($id)
5959
{
6060
$batch = $this->batches->find($id);
6161

62-
$failedJobs = app(JobRepository::class)
63-
->getJobs($batch->failedJobIds);
62+
$failedJobs = $batch
63+
? app(JobRepository::class)->getJobs($batch->failedJobIds)
64+
: null;
6465

6566
return [
6667
'batch' => $batch,

0 commit comments

Comments
 (0)