Commit a979f30b authored by Mahmoud Aglan's avatar Mahmoud Aglan

Add guardian profession and workplace to registration wizard and participant view

Fields already existed on the guardians table (occupation, workplace) but
had no UI. Now:
- Registration wizard step 2 shows المهنة + جهة العمل fields (optional)
- Saved to Guardian on create; updates existing guardian if already found
- Pre-populated when selecting an existing guardian via search
- Participant show → أولياء الأمور tab adds المهنة / جهة العمل column
Co-Authored-By: 's avatarClaude Sonnet 4.6 <noreply@anthropic.com>
parent 85319db6
...@@ -64,6 +64,8 @@ class NewRegistrationWizard extends Component ...@@ -64,6 +64,8 @@ class NewRegistrationWizard extends Component
public string $guardian_name = ''; public string $guardian_name = '';
public string $guardian_phone = ''; public string $guardian_phone = '';
public string $guardian_relation = 'father'; public string $guardian_relation = 'father';
public string $guardian_occupation = '';
public string $guardian_workplace = '';
// Step 3: Parent Account // Step 3: Parent Account
public bool $createParentAccount = true; public bool $createParentAccount = true;
...@@ -290,6 +292,8 @@ private function rulesForStep(int $step): array ...@@ -290,6 +292,8 @@ private function rulesForStep(int $step): array
'guardian_name_ar' => 'required|string|max:255', 'guardian_name_ar' => 'required|string|max:255',
'guardian_phone' => 'required|string|max:20', 'guardian_phone' => 'required|string|max:20',
'guardian_relation' => 'required|in:father,mother,brother,sister,uncle,aunt,grandfather,grandmother,guardian,other', 'guardian_relation' => 'required|in:father,mother,brother,sister,uncle,aunt,grandfather,grandmother,guardian,other',
'guardian_occupation' => 'nullable|string|max:150',
'guardian_workplace' => 'nullable|string|max:150',
], ],
3 => $this->createParentAccount ? [ 3 => $this->createParentAccount ? [
'parentEmail' => 'required|email|max:255|unique:users,email', 'parentEmail' => 'required|email|max:255|unique:users,email',
...@@ -478,6 +482,8 @@ public function selectExistingGuardian(int $guardianId): void ...@@ -478,6 +482,8 @@ public function selectExistingGuardian(int $guardianId): void
$this->guardian_name = $guardian->person->name ?? ''; $this->guardian_name = $guardian->person->name ?? '';
$this->guardian_phone = $guardian->person->phone ?? ''; $this->guardian_phone = $guardian->person->phone ?? '';
$this->guardian_relation = $guardian->relation_type ?? 'father'; $this->guardian_relation = $guardian->relation_type ?? 'father';
$this->guardian_occupation = $guardian->occupation ?? '';
$this->guardian_workplace = $guardian->workplace ?? '';
$this->guardianSelected = true; $this->guardianSelected = true;
$this->guardianSearchResults = []; $this->guardianSearchResults = [];
} }
...@@ -489,6 +495,8 @@ public function clearSelectedGuardian(): void ...@@ -489,6 +495,8 @@ public function clearSelectedGuardian(): void
$this->guardian_name = ''; $this->guardian_name = '';
$this->guardian_phone = ''; $this->guardian_phone = '';
$this->guardian_relation = 'father'; $this->guardian_relation = 'father';
$this->guardian_occupation = '';
$this->guardian_workplace = '';
$this->guardianSelected = false; $this->guardianSelected = false;
$this->searchExistingGuardian = false; $this->searchExistingGuardian = false;
$this->guardianSearchQuery = ''; $this->guardianSearchQuery = '';
...@@ -762,11 +770,20 @@ public function confirm(): void ...@@ -762,11 +770,20 @@ public function confirm(): void
[ [
'academy_id' => app('current_academy')->id, 'academy_id' => app('current_academy')->id,
'relationship_type' => $this->guardian_relation, 'relationship_type' => $this->guardian_relation,
'occupation' => $this->guardian_occupation ?: null,
'workplace' => $this->guardian_workplace ?: null,
'is_emergency_contact' => true, 'is_emergency_contact' => true,
'is_financial_responsible' => true, 'is_financial_responsible' => true,
'can_pickup' => true, 'can_pickup' => true,
] ]
); );
// Update occupation/workplace if guardian already existed
if (!$guardian->wasRecentlyCreated && ($this->guardian_occupation || $this->guardian_workplace)) {
$guardian->update([
'occupation' => $this->guardian_occupation ?: $guardian->occupation,
'workplace' => $this->guardian_workplace ?: $guardian->workplace,
]);
}
// 2b. Create parent User account if requested // 2b. Create parent User account if requested
if ($this->createParentAccount && $this->parentEmail) { if ($this->createParentAccount && $this->parentEmail) {
......
...@@ -376,6 +376,7 @@ class="pb-3 border-b-2 text-sm font-medium transition whitespace-nowrap"> ...@@ -376,6 +376,7 @@ class="pb-3 border-b-2 text-sm font-medium transition whitespace-nowrap">
<tr> <tr>
<th class="px-4 py-3 text-start font-medium text-gray-600">{{ __('الاسم') }}</th> <th class="px-4 py-3 text-start font-medium text-gray-600">{{ __('الاسم') }}</th>
<th class="px-4 py-3 text-start font-medium text-gray-600">{{ __('صلة القرابة') }}</th> <th class="px-4 py-3 text-start font-medium text-gray-600">{{ __('صلة القرابة') }}</th>
<th class="px-4 py-3 text-start font-medium text-gray-600">{{ __('المهنة / جهة العمل') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('أساسي') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('أساسي') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('طوارئ') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('طوارئ') }}</th>
<th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('استلام') }}</th> <th class="px-4 py-3 text-center font-medium text-gray-600">{{ __('استلام') }}</th>
...@@ -396,6 +397,17 @@ class="pb-3 border-b-2 text-sm font-medium transition whitespace-nowrap"> ...@@ -396,6 +397,17 @@ class="pb-3 border-b-2 text-sm font-medium transition whitespace-nowrap">
@endphp @endphp
{{ __($relLabels[$guardian->pivot->relationship_type] ?? $guardian->pivot->relationship_type ?? '—') }} {{ __($relLabels[$guardian->pivot->relationship_type] ?? $guardian->pivot->relationship_type ?? '—') }}
</td> </td>
<td class="px-4 py-3 text-gray-600">
@if($guardian->occupation)
<span class="font-medium text-gray-700">{{ $guardian->occupation }}</span>
@endif
@if($guardian->workplace)
<p class="text-xs text-gray-500">{{ $guardian->workplace }}</p>
@endif
@if(!$guardian->occupation && !$guardian->workplace)
<span class="text-gray-400"></span>
@endif
</td>
<td class="px-4 py-3 text-center"> <td class="px-4 py-3 text-center">
@if($guardian->pivot->is_primary) @if($guardian->pivot->is_primary)
<span class="text-green-600">{{ __('نعم') }}</span> <span class="text-green-600">{{ __('نعم') }}</span>
......
...@@ -405,6 +405,24 @@ class="w-full px-4 py-3 min-h-[52px] border border-gray-300 rounded-lg focus:rin ...@@ -405,6 +405,24 @@ class="w-full px-4 py-3 min-h-[52px] border border-gray-300 rounded-lg focus:rin
</div> </div>
@error('guardian_relation') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror @error('guardian_relation') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div> </div>
{{-- Occupation & Workplace --}}
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 mt-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('المهنة') }}</label>
<input type="text" wire:model="guardian_occupation"
class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm"
placeholder="{{ __('مثال: مهندس، طبيب، معلم...') }}">
@error('guardian_occupation') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">{{ __('جهة العمل') }}</label>
<input type="text" wire:model="guardian_workplace"
class="w-full px-4 py-3 border border-gray-300 rounded-xl focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-sm"
placeholder="{{ __('اسم الشركة أو المؤسسة') }}">
@error('guardian_workplace') <p class="mt-1 text-sm text-red-600">{{ $message }}</p> @enderror
</div>
</div>
</div> </div>
@endif @endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment