From d3f0cc8e5bf90505321042ddd38dd25e6d986650 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Thu, 5 Feb 2026 09:49:28 +0000 Subject: [PATCH] tweaks --- app/Imports/GenericEventsImport.php | 23 ++++++++++++------- .../views/admin/bulk-upload/report.blade.php | 8 +++---- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/app/Imports/GenericEventsImport.php b/app/Imports/GenericEventsImport.php index 52284d30a..f448adfa2 100644 --- a/app/Imports/GenericEventsImport.php +++ b/app/Imports/GenericEventsImport.php @@ -101,10 +101,10 @@ protected function validateCoordinates(array $row): ?string return null; } if ($lat === null || $lon === null) { - return 'Invalid latitude/longitude (must be numeric)'; + return 'value must be numeric'; } if ($lat < -90 || $lat > 90 || $lon < -180 || $lon > 180) { - return 'Bad coordinates (latitude -90 to 90, longitude -180 to 180)'; + return 'latitude must be -90 to 90, longitude -180 to 180'; } return null; } @@ -177,7 +177,7 @@ public function model(array $row): ?Model // 1) coordinate validation $coordError = $this->validateCoordinates($row); if ($coordError !== null) { - $this->recordFailure($rowIndex, $coordError); + $this->recordFailure($rowIndex, 'Row ' . $rowIndex . ' — columns latitude, longitude: ' . $coordError); Log::warning($coordError, $row); return null; } @@ -200,8 +200,7 @@ public function model(array $row): ?Model } } if ($missing !== []) { - $reason = 'Missing required field(s): '.implode(', ', $missing); - $this->recordFailure($rowIndex, $reason); + $this->recordFailure($rowIndex, 'Row ' . $rowIndex . ' — missing required columns: ' . implode(', ', $missing)); Log::error('Missing required fields, skipping row.', $row); return null; } @@ -209,14 +208,22 @@ public function model(array $row): ?Model $startDate = $this->parseDate($row['start_date']); $endDate = $this->parseDate($row['end_date']); if ($startDate === null || $endDate === null) { - $this->recordFailure($rowIndex, 'Invalid date format for start_date or end_date'); + $badDates = []; + if ($startDate === null && trim((string) ($row['start_date'] ?? '')) !== '') { + $badDates[] = 'start_date'; + } + if ($endDate === null && trim((string) ($row['end_date'] ?? '')) !== '') { + $badDates[] = 'end_date'; + } + $colList = $badDates !== [] ? implode(', ', $badDates) : 'start_date, end_date'; + $this->recordFailure($rowIndex, 'Row ' . $rowIndex . ' — invalid date format in column(s): ' . $colList); return null; } // 3) resolve creator_id $creatorId = $this->resolveCreatorId($row); if ($creatorId === null && ! empty(trim($row['contact_email'] ?? ''))) { - $this->recordFailure($rowIndex, 'Could not resolve or create user for contact_email'); + $this->recordFailure($rowIndex, 'Row ' . $rowIndex . ' — could not resolve or create user (column: contact_email)'); return null; } @@ -355,7 +362,7 @@ public function model(array $row): ?Model $this->recordCreated($event); return $event; } catch (\Exception $e) { - $this->recordFailure($rowIndex, 'Event import failed: '.$e->getMessage()); + $this->recordFailure($rowIndex, 'Row ' . $rowIndex . ' — save failed: ' . $e->getMessage()); Log::error('Event import failed: '.$e->getMessage(), $attrs); return null; } diff --git a/resources/views/admin/bulk-upload/report.blade.php b/resources/views/admin/bulk-upload/report.blade.php index a58515d36..782fbd684 100644 --- a/resources/views/admin/bulk-upload/report.blade.php +++ b/resources/views/admin/bulk-upload/report.blade.php @@ -22,19 +22,19 @@ @if (count($failures) > 0)

Failures ({{ count($failures) }})

-

Row number refers to the row in the Excel file (header = row 1).

+

Row is the Excel row number (header = row 1). Reason shows which columns have issues so you can fix the file and re-upload.

- + @foreach ($failures as $rowIndex => $reason) - - + + @endforeach
RowReasonReason (row and columns)
{{ $rowIndex }}{{ $reason }}{{ $rowIndex }}{{ $reason }}