From d75602803c9831d63c77eba6bc56819deed75017 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Tue, 27 Jan 2026 16:56:49 +0000 Subject: [PATCH] matchmalking bulk --- app/Imports/MatchmakingProfileImport.php | 37 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/app/Imports/MatchmakingProfileImport.php b/app/Imports/MatchmakingProfileImport.php index 9ac3b298c..e373aae27 100644 --- a/app/Imports/MatchmakingProfileImport.php +++ b/app/Imports/MatchmakingProfileImport.php @@ -232,13 +232,17 @@ protected function findCountryIso($countryName): ?string } /** - * Generate slug from organisation name or email + * Generate slug from a base string */ - protected function generateSlug($organisationName, $email): string + protected function generateSlug(string $base): string { - $base = !empty($organisationName) ? $organisationName : $email; + $base = trim($base); $slug = Str::slug($base); - + + if ($slug === '') { + $slug = 'profile'; + } + // Ensure uniqueness $originalSlug = $slug; $counter = 1; @@ -246,7 +250,7 @@ protected function generateSlug($organisationName, $email): string $slug = $originalSlug . '-' . $counter; $counter++; } - + return $slug; } @@ -509,17 +513,32 @@ public function model(array $row): ?Model $lastName = count($parts) ? implode(' ', $parts) : null; } + // Build slug base + $slugBase = null; + if ($type === MatchmakingProfile::TYPE_VOLUNTEER) { + $nameParts = array_filter([trim((string) $firstName), trim((string) $lastName)]); + if (!empty($nameParts)) { + $slugBase = implode(' ', $nameParts); + } elseif (!empty($fullName)) { + $slugBase = $fullName; + } elseif (!empty($email)) { + $slugBase = $email; + } else { + $slugBase = $organisationName ?: 'profile'; + } + } else { + $slugBase = $organisationName ?: ($email ?: 'profile'); + } + Log::info('[MatchmakingProfileImport] Processing row', [ 'type' => $type, 'email' => $email, 'organisation_name' => $organisationName, + 'slug_base' => $slugBase, ]); // Generate slug - $slug = $this->generateSlug( - $organisationName ?? '', - $email ?? 'anonymous' - ); + $slug = $this->generateSlug($slugBase); // Parse organisation type $organisationType = [];