@extends('themes.one.master') @section('title', __('Online Admission')) @section('content') @php $root = $data['data'] ?? $data; $title = $root['title'] ?? __('Online Admission Form'); $genderList = $root['genderList'] ?? []; $classList = $root['classList'] ?? []; $bloodgroup = $root['bloodgroup'] ?? []; $flags = $root['field_list'] ?? []; $isRequired = fn($k) => isset($flags[$k]) && $flags[$k] == '1'; $isPresent = fn($k) => array_key_exists($k, $flags); // Smart type detection (auto-decide field input type) $detectType = function ($key) { $key = strtolower($key); return match (true) { str_contains($key, 'date') => 'date', str_contains($key, 'dob') => 'date', str_contains($key, 'email') => 'email', str_contains($key, 'photo') || str_contains($key, 'pic') || str_contains($key, 'document') => 'file', str_contains($key, 'address') || str_contains($key, 'details') || str_contains($key, 'note') => 'textarea', str_contains($key, 'height') || str_contains($key, 'weight') => 'number', default => 'text', }; }; // Grouping logic $sections = [ 'Student Information' => [ 'firstname','middlename','lastname','dob','class_id','gender','category','religion','cast', 'mobile_no','admission_date','is_blood_group','student_height','student_weight','student_email','Number' ], 'Parents / Guardian' => [ 'father_name','father_phone','father_occupation','mother_name','mother_phone','mother_occupation', 'guardian_name','guardian_relation','guardian_phone','guardian_email','guardian_occupation' ], 'Addresses' => [ 'current_address','permanent_address','guardian_address' ], 'Additional Details' => [ 'bank_account_no','bank_name','ifsc_code','national_identification_no','local_identification_no', 'previous_school_details','student_note' ], 'Documents & Photos' => [ 'student_photo','document','father_pic','mother_pic','guardian_photo' ] ]; // Flatten all section keys for matching $knownKeys = collect($sections)->flatten()->toArray(); // Auto-labels $prettyLabel = fn($k) => ucwords(str_replace('_', ' ', preg_replace('/^(is_)/', '', $k))); @endphp

{{ $title }}

Session: {{ $root['session'] ?? '-' }} {{-- Alerts --}} @if ($errors->any())
    @foreach($errors->all() as $e)
  • {{ $e }}
  • @endforeach
@endif @if(session('success'))
{{ session('success') }}
@endif @error('submission')
{{ $message }}
@enderror
@csrf {{-- === Dynamic Section Rendering === --}} @foreach($sections as $sectionTitle => $fieldKeys) @php $visible = collect($fieldKeys)->contains(fn($f)=>$isPresent($f)); @endphp @if($visible)
{{ $sectionTitle }}
@foreach($fieldKeys as $key) @if($isPresent($key)) @php $type = $detectType($key); @endphp
{{-- Smart Input Rendering --}} @switch($key) @case('class_id') @break @case('gender') @break @case('is_blood_group') @break @default @if($type === 'textarea') @elseif($type === 'file') @else @endif @endswitch @error($key)
{{ $message }}
@enderror
@endif @endforeach

@endif @endforeach {{-- Fallback: unknown/new fields --}} @php $unknownFields = collect($flags) ->keys() ->filter(fn($k)=>!in_array($k,$knownKeys)) ->toArray(); @endphp @if(count($unknownFields))
{{ __('Other Fields') }}
@foreach($unknownFields as $key)
@endforeach
@endif

{{ __('Fields marked with') }} * {{ __('are required') }}.

@endsection