fix(profile): sync User.real_name from profile name on create/update
When a user completes their profile (POST/PATCH /api/v1/user-profile), the name was only stored on the profile (label/family) and User.real_name stayed empty — so users who registered via booking showed with no name in the admin user list. hydrate() now mirrors the profile's full name (label + family) onto the owning User.realName, persisted in the same flush. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -182,5 +182,12 @@ class UserProfileController extends BaseController
|
||||
: $data['other'];
|
||||
$profile->setOther($other);
|
||||
}
|
||||
|
||||
// Keep the owning user's display name (real_name) in sync with the profile,
|
||||
// so admin user listings and anywhere reading real_name show a name.
|
||||
if (array_key_exists('name', $data) || array_key_exists('label', $data) || array_key_exists('family', $data)) {
|
||||
$fullName = trim(implode(' ', array_filter([$profile->getLabel(), $profile->getFamily()])));
|
||||
$profile->getUser()->setRealName($fullName !== '' ? $fullName : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user