<table>
    <thead>
            <tr>
                <th colspan="{{ count($columns) + (in_array('SL', $columns) ? 1 : 0) }}" style="font-weight: bold; font-size: 14px; text-align: center; white-space: pre-wrap;">
                    {{ $institute_name ?? 'N/A' }}
                </th> 
            </tr>
            <tr>
                <th colspan="{{ count($columns) + (in_array('SL', $columns) ? 1 : 0) }}" style="text-align: center;">
                    {{ $report_title ?? 'N/A' }} (Class: {{ $class_name ?? 'N/A' }}) (Shift: {{ $shift_name ?? 'N/A' }}) ( Type : {{ $attendance_type ?? 'N/A' }})  (Date: {{ $form_date ?? 'N/A' }} To {{ $to_date ?? 'N/A' }}) 
                </th> 
            </tr>
        <tr>
            @foreach($columns as $column)
                @if($column == 'student_id')
                <th>Student ID</th>
                @elseif($column == 'roll')
                <th>Roll</th>
                @elseif($column == 'student_name')
                <th>Name</th>
                @elseif($column == 'mobile_number')
                <th>Mobile Number</th>
                @elseif($column == 'total_count')
                <th>Count</th>
                @endif
            @endforeach
        </tr>
    </thead>
    <tbody>
        @foreach($attendances as $attendance)
            <tr>
                @foreach($columns as $column)
                    @if($column == 'student_id')
                        <td>{{ $attendance->StudentInfo->student_id_no ?? 'N/A' }}</td>
                    @elseif($column == 'roll')
                        <td>{{ $attendance->StudentInfo->class_roll ?? 'N/A' }}</td>
                    @elseif($column == 'student_name')
                        <td>{{ $attendance->StudentInfo->first_name ?? 'N/A' }} {{ $attendance->StudentInfo->last_name ?? 'N/A' }}</td>
                    @elseif($column == 'mobile_number')    
                        <td>{{ $attendance->StudentInfo->guardian_mobile ?? 'N/A' }}</td>        
                    @elseif($column == 'total_count')    
                        <td>
                            {{ $attendance->total_count ?? 'N/A' }}
                        </td>       
                    @endif
                @endforeach
            </tr>
        @endforeach
    </tbody>
</table>