@extends('themes.six.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 $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', }; }; $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' ], ]; $knownKeys = collect($sections)->flatten()->toArray(); $prettyLabel = fn($k) => ucwords(str_replace('_', ' ', preg_replace('/^(is_)/', '', $k))); @endphp

{{ $title }}

Session: {{ $root['session'] ?? '-' }}
@if ($errors->any())
    @foreach($errors->all() as $e)
  • {{ $e }}
  • @endforeach
@endif @if(session('success'))
{{ session('success') }}
@endif @error('submission')
{{ $message }}
@enderror
@csrf
{{-- === Auto-rendered Sections === --}} @foreach($sections as $sectionTitle => $fields) @php $visible = collect($fields)->contains(fn($f)=>$isPresent($f)); @endphp @if($visible)

{{ $sectionTitle }}

@foreach($fields as $key) @if($isPresent($key)) @php $type = $detectType($key); @endphp
@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 {{-- Unknown / future 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 as per upstream configuration.

@endsection