Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/Imports/MatchmakingProfileImport.php
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,20 @@ public function model(array $row): ?Model
// Only set slug if creating new profile
if (!$existingProfile) {
$profileData['slug'] = $slug;
} else {
// For volunteers, update slug if it was previously based on organisation name or is missing
if ($type === MatchmakingProfile::TYPE_VOLUNTEER) {
$currentSlug = $existingProfile->slug ?? '';
$orgSlug = $organisationName ? Str::slug($organisationName) : '';
$existingOrgSlug = $existingProfile->organisation_name ? Str::slug($existingProfile->organisation_name) : '';
$shouldUpdateSlug = empty($currentSlug)
|| (!empty($orgSlug) && $currentSlug === $orgSlug)
|| (!empty($existingOrgSlug) && $currentSlug === $existingOrgSlug);

if ($shouldUpdateSlug && !empty($slug)) {
$profileData['slug'] = $slug;
}
}
}

// For updates, we want to include all fields (even null) to properly update
Expand Down