'how can i pass parameter inside the then function and catch funtion of laravel Bus::batch
while passing the id in then function its value goes null but I want the inside then and catch function so I can update the response value to the mongo DB OR if it is possible to find the id of batch inside then function which is not getting
$batch = Bus::batch($jobs)
->then(function (Batch $batch , $id) {
$data = [
'batchResponse' => [
'status' => 'success',
'created_at' => Carbon::now()->toDateTimeString(),
'data' => [
'message' => 'Queue processed successfully.',
'batch' => $batch,
]
],
];
logging($data);
loggingMongodb($data, $id);
})->catch(function (Batch $batch, Throwable $e , $id) {
$data = [
'batchResponse' => [
'status' => 'failure',
'created_at' => Carbon::now()->toDateTimeString(),
'data' => [
'message' => 'Queue filed to process.',
'batch' => $batch,
'exception' => $e->getMessage(),
]
],
];
logging($data);
loggingMongodb($data, $id);
})->name('Mail Batch Process')->dispatch();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
