fix(profile): persist & expose birthday as a single Unix field

Birthday was never saved (hydrate forced null) and not returned in a form the
clients use. Now:
- hydrate stores the incoming `birthday` (Unix) into date_of_birth; `birthday`
  takes priority over a stray `date_of_birth: null` in the same payload so it
  can't be wiped.
- toArray exposes a single `birthday` (Unix) key — drop the duplicate
  `date_of_birth` output to avoid overlap.
- admin UserDetailPage reads profile.birthday (formatDate renders Jalali).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-16 11:42:31 +03:30
co-authored by Claude Opus 4.8
parent 800f9ad8cd
commit b60dbdadba
4 changed files with 90 additions and 9 deletions
@@ -155,13 +155,16 @@ class UserProfileController extends BaseController
);
if (array_key_exists('sharing_with_user', $data)) $profile->setSharingWithUser((bool) $data['sharing_with_user']);
// birthday: accept Jalali string "1370-05-15" stored as-is converted to Unix
if (array_key_exists('birthday', $data) && $data['birthday'] !== null) {
// Store as string-encoded Unix; for now keep as null if conversion unavailable
// Will be replaced with JalaliDateService in Task 16
$profile->setDateOfBirth(null);
// birthday / date_of_birth: Unix timestamp (frontend converts Jalali↔Unix
// via changeDateType). `birthday` takes priority; `date_of_birth` is only a
// fallback so a stray `date_of_birth: null` in the payload can't wipe it.
if (array_key_exists('birthday', $data)) {
$b = $data['birthday'];
$profile->setDateOfBirth(($b === null || $b === '') ? null : (int) $b);
} elseif (array_key_exists('date_of_birth', $data)) {
$b = $data['date_of_birth'];
$profile->setDateOfBirth(($b === null || $b === '') ? null : (int) $b);
}
if (array_key_exists('date_of_birth', $data)) $profile->setDateOfBirth($data['date_of_birth']);
// Insurance references (category IDs)
if (array_key_exists('basic_insurance', $data)) {