diff --git a/src/Http/Controllers/BatchesController.php b/src/Http/Controllers/BatchesController.php index 53e88ae3..3f092928 100644 --- a/src/Http/Controllers/BatchesController.php +++ b/src/Http/Controllers/BatchesController.php @@ -59,12 +59,14 @@ public function show($id) { $batch = $this->batches->find($id); - $failedJobs = app(JobRepository::class) - ->getJobs($batch->failedJobIds); + if ($batch) { + $failedJobs = app(JobRepository::class) + ->getJobs($batch->failedJobIds); + } return [ 'batch' => $batch, - 'failedJobs' => $failedJobs, + 'failedJobs' => $failedJobs ?? null, ]; } @@ -78,14 +80,16 @@ public function retry($id) { $batch = $this->batches->find($id); - app(JobRepository::class) - ->getJobs($batch->failedJobIds) - ->reject(function ($job) { - $payload = json_decode($job->payload); + if ($batch) { + app(JobRepository::class) + ->getJobs($batch->failedJobIds) + ->reject(function ($job) { + $payload = json_decode($job->payload); - return isset($payload->retry_of); - })->each(function ($job) { - dispatch(new RetryFailedJob($job->id)); - }); + return isset($payload->retry_of); + })->each(function ($job) { + dispatch(new RetryFailedJob($job->id)); + }); + } } }