@extends('template.layouts.template-base') @section('title') Edit Candidate | {{ config('setting.website_name') ?: config('app.name') }} @endsection @section('content') @php // The list the candidate is on: onboarding, shortlist or hiring [$listRoute, $listTitle] = match (true) { $recruitment->isOnboarded() => ['backend.recruitment.onboarding', 'Onboarding'], $recruitment->isShortlisted() => ['backend.recruitment.shortlist', 'Shortlisted'], default => ['backend.recruitment.index', 'Hiring'], }; $listUrl = route($listRoute); // Opened from the All Staff list: Cancel and Submit go back to it with the same filters $allStaff = $recruitment->isOnboarded() ? \App\Http\Controllers\RecruitmentController::allStaffFilters(request()) : null; if ($allStaff !== null) { [$listUrl, $listTitle] = [route('backend.all-staff.index', $allStaff), 'Staffs List']; } @endphp
@php $educationOptions = ['Below SSLC', 'SSLC', 'HSC / 12th', 'Diploma', 'ITI', 'Undergraduate', 'B.A', 'B.Sc', 'B.Com', 'BBA', 'BCA', 'B.E / B.Tech', 'MBBS', 'B.Pharm', 'Postgraduate', 'M.A', 'M.Sc', 'M.Com', 'MBA', 'MCA', 'M.E / M.Tech', 'M.Pharm', 'PhD', 'Others']; $staffType = old('staff_type', $recruitment->staff_type); @endphp {{-- Same fields as the Add Candidate page; no field is mandatory --}}
@csrf @if ($allStaff !== null) @foreach (\Illuminate\Support\Arr::except($allStaff, 'employee_view') as $filter => $filterValue) @endforeach @endif

Personal Details

@error('staff_type')
{{ $message }}
@enderror
@error('clients')
{{ $message }}
@enderror
@error('projects')
{{ $message }}
@enderror
@error('application_id')
{{ $message }}
@enderror
{{-- Category: the Wages Settings categories of the selected client / project --}} @php $selectedCategory = old('category', $recruitment->category); // A saved category that is no longer in the Wages Settings stays selectable $categoryOptions = collect($categories)->push($selectedCategory)->filter()->unique()->values(); @endphp
{{ $categoryOptions->isEmpty() ? 'Select a client or project to see its categories.' : '' }}
@error('category')
{{ $message }}
@enderror
@error('aadhar_no')
{{ $message }}
@enderror
@error('name')
{{ $message }}
@enderror
{{-- Gender --}}
@error('dob')
{{ $message }}
@enderror
@error('age')
{{ $message }}
@enderror
@error('gender')
{{ $message }}
@enderror
{{-- Marital Status --}}
@error('marital_status')
{{ $message }}
@enderror
{{-- Blood Group --}}
@error('mobile_no')
{{ $message }}
@enderror
@error('email')
{{ $message }}
@enderror
@php // Wellbeing rows: the submitted rows after a validation error, else the saved rows, else one empty row $medicalHistories = old('medical_history', json_decode($recruitment->medical_history ?? '', true) ?: ['']); $otherMedicals = old('other_medical', json_decode($recruitment->other_medical ?? '', true) ?: []); @endphp

Candidate Wellbeing

@foreach ($medicalHistories as $index => $history)
@endforeach
@php $educations = old('education', $recruitment->education ?: ['']); $majors = old('major', $recruitment->major ?: []); @endphp

Educational Details

@foreach ($educations as $index => $education)
@endforeach
@php // A candidate saved before Fresher / Experience existed is experienced when Re-Joining was filled $experienceType = old('experience_type', $recruitment->experience_type ?: ($recruitment->re_joining ? 'Experience' : null)); @endphp
Experience
@error('experience_type')
{{ $message }}
@enderror
{{-- Re-Joining and Years only apply to an experienced candidate --}}
@error('re_joining')
{{ $message }}
@enderror
@error('experience_years')
{{ $message }}
@enderror
@php // Family members: the submitted rows after a validation error, else the saved rows if (old('family_name') !== null) { $familyMembers = collect(old('family_name'))->keys()->map(fn ($i) => [ 'name' => old('family_name.' . $i), 'gender' => old('family_gender.' . $i), 'relationship' => old('family_relationship.' . $i), 'contact_number' => old('family_contact_number.' . $i), ])->values(); } else { $familyMembers = json_decode($recruitment->family_details ?? '', true); // A candidate saved before Family Details had rows: father, mother and emergency contact become rows if (!is_array($familyMembers)) { $familyMembers = collect([ ['name' => $recruitment->father_name, 'relationship' => 'Father'], ['name' => $recruitment->mother_name, 'relationship' => 'Mother'], ['name' => $recruitment->contact_preson_name, 'contact_number' => $recruitment->contact_preson_number], ])->filter(fn ($member) => filled($member['name']) || filled($member['contact_number'] ?? null))->values(); } } @endphp

Family Details

{{-- One row per family member; the + button adds another row from the template below --}}
@foreach (['family_name', 'family_gender', 'family_relationship', 'family_contact_number'] as $familyField) @foreach ($errors->get($familyField . '.*') as $familyMessages)
{{ $familyMessages[0] }}
@endforeach @endforeach
{{-- Nominee --}}

Nominee

@error('nominee_name')
{{ $message }}
@enderror
@error('nominee_relationship')
{{ $message }}
@enderror
@error('nominee_contact_number')
{{ $message }}
@enderror
{{-- Address Details --}} @php // Every address column is a JSON list: first the current address, then the permanent address $savedAddresses = []; foreach (['building_no', 'address1', 'address2', 'city', 'district', 'state', 'country', 'pincode'] as $column) { $values = json_decode($recruitment->$column ?? '', true); foreach (is_array($values) ? array_values($values) : [$recruitment->$column] as $i => $value) { $savedAddresses[$i][$column] = $value; } } // Current and permanent address are always shown; more only for a candidate saved with more $addressCount = max(2, count(old('building_no', $savedAddresses))); @endphp

Address Details

@for ($i = 0; $i < $addressCount; $i++)
@if ($i == 0)
Registered Current Address
@else
Registered Permanent Address
{{-- Saved as 1 / 0 for the permanent address --}} same_as_current) @endif>
@endif
@include('template.recruitment.partials.address-fields', [ 'index' => $i, 'address' => $savedAddresses[$i] ?? [], ])
@endfor
{{-- Submit --}}
Cancel @if ($recruitment->is_draft) @endif
@endsection @section('scripts') @endsection