argument('path'); if (!file_exists($path)) { $this->error("File not found: {$path}"); return 1; } $this->info("Starting tracking data import from: {$path}"); $this->newLine(); try { $import = new TrackingDataImport(); Excel::import($import, $path); $imported = $import->getImportedEvents(); $skipped = $import->getSkippedEvents(); $errors = $import->getErrors(); $createdShipments = $import->getCreatedShipments(); $this->info("Import completed successfully!"); $this->newLine(); $this->table( ['Metric', 'Count'], [ ['Imported Events', $imported], ['Skipped Events', $skipped], ['Created Shipments', $createdShipments], ['Errors', count($errors)], ] ); if ($errors) { $this->newLine(); $this->warn('Errors:'); foreach (array_slice($errors, 0, 20) as $error) { $this->error(" - {$error}"); } if (count($errors) > 20) { $this->warn(" ... and " . (count($errors) - 20) . " more errors"); } } Log::info('Tracking import command completed', [ 'path' => $path, 'imported' => $imported, 'skipped' => $skipped, 'errors' => count($errors), ]); return 0; } catch (\Throwable $e) { $this->error("Import failed: " . $e->getMessage()); Log::error('Tracking import command failed', [ 'path' => $path, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString(), ]); return 1; } } }