Я пытаюсь отложить задание, которое добавляется в пакет в моем приложении Laravel, но при попытке добавить отложенное задание возникает ошибка. Чего мне не хватает в моем коде?
< pre class="lang-php Prettyprint-override">/**
* Create chunked CSVs
*/
protected function createChunkedCSVs(Request $request)
{
try {
// get the CSV we stored
$data = file($request->csv);
// chunk the CSV into smaller csv's
$chunks = array_chunk($data, 1000);
// header and batch
$header = [];
$batch = Bus::batch([])->dispatch();
// latest form release
$release = $this->getApplicationFormVersion();
// begin chunking
foreach ($chunks as $key => $chunk) {
$data = array_map('str_getcsv', $chunk);
if ($key === 0) {
$header = $data[0];
unset($data[0]);
}
$batch->add(new CustomersCsvProcess($data, $header, $release)->delay(Carbon::now()->addMinutes(5)));
}
// return the batch
return $batch;
} catch (\Exception $e) {
return null;
}
}
Подробнее здесь: https://stackoverflow.com/questions/676 ... with-batch