import->type) { case 'orders': (new ImportOrdersService($this->import))->handle(); break; case 'mafs': (new ImportMafsService($this->import))->handle(); break; case 'reclamations': (new ImportReclamationsService($this->import))->handle(); break; case 'catalog': (new ImportCatalogService($this->import, $this->import->year))->handle(); break; case 'spare_part_orders': $this->handleSparePartOrdersImport(); break; } Log::info('Import ' . $this->import->type. ' job done!'); event(new SendWebSocketMessageEvent('Импорт завершён!', $this->userId, ['path' => $this->import->filename, 'type' => $this->import->type])); } catch (Exception $e) { Log::info('Import ' . $this->import->type. ' job failed! ERROR: ' . $e->getMessage()); event(new SendWebSocketMessageEvent('Ошибка импорта! ' . $e->getMessage(), $this->userId, ['error' => $e->getMessage()])); } } private function handleSparePartOrdersImport(): void { $filePath = Storage::disk('upload')->path($this->import->filename); $service = new ImportSparePartOrdersService($filePath, $this->userId); $result = $service->handle(); // Записываем логи в Import foreach ($service->getLogs() as $logLine) { $this->import->log($logLine); } $this->import->status = $result['success'] ? 'DONE' : 'ERROR'; $this->import->save(); } }