@extends('admin.admin_dashboard') @section('admin') @php // safety fallbacks $existing = isset($existing) ? $existing : collect(); $isNew = isset($isNew) ? $isNew : ($existing->count() === 0); $showOptionalCols = isset($registration->class_id) ? ($registration->class_id > 8) : false; @endphp
{{-- Student image --}}
Student Photo
{{ $registration->student->student_name_english ?? 'N/A' }}

Admission Roll: {{ $registration->student->admission_roll ?? 'N/A' }}

Class: {{ $registration->class->name ?? 'N/A' }} Section: {{ $registration->section->name ?? 'N/A' }}

Group: {{ $registration->group->name ?? 'N/A' }} Class Roll: {{ $registration->class_roll ?? 'N/A' }}

Session: {{ $registration->session->name ?? 'N/A' }}

@if(session('error'))
{{ session('error') }}
@endif @if(session('success'))
{{ session('success') }}
@endif
@csrf
Subjects for Class {{ $registration->class->name }}
@if(!$isNew) {{-- @csrf --}} @endif
@if($showOptionalCols) @endif @foreach($subjects as $subject) @php // $existing is keyed by subject_id (collection). If not keyed, adapt accordingly. $map = isset($existing[$subject->id]) ? $existing[$subject->id] : null; @endphp {{-- Take checkbox: checked if existing mapping present OR if this is a new mapping --}} @if($showOptionalCols) {{-- Is Main --}} {{-- Is Optional (fourth) --}} @endif @endforeach
Subject Name TakeIs Main Is Optional (Fourth)
{{ $subject->name }} is_main ? 'checked' : '') : ($isNew ? 'checked' : '') }}> is_fourth ? 'checked' : '') : '' }}>
@endsection {{-- Scripts --}} @section('scripts') @endsection