@extends('layouts.header')

@section('content')
<main>
    <div class="container-fluid px-4">
        <h1 class="mt-4">Dashboard</h1>
        <ol class="breadcrumb mb-4">
            <li class="breadcrumb-item active">Dashboard</li>
        </ol>
        <div class="row">
            <div class="col-xl-12">
                <div class="card mb-4">
                    <div class="card-header">
                        <i class="fas fa-table me-1"></i>
                        Student Details
                    </div>
                    <div class="card-body">
                        <table id="datatablesSimple" class="table">
                            <thead>
                                <tr>
                                    <th>#</th>
                                    <th>Student Name</th>
                                    <th>Age</th>
                                    <th>Date of Birth</th>
                                    <th>Gender</th>
                                    <th>Guardian Name</th>
                                    <th>Communication Address</th>
                                    <th>Contact Phone</th>
                                    <th>Class</th>
                                    <th>Standard</th>
                                    <th>Last Exam Marks</th>
                                    <th>School Details</th>
                                    <th>Student Image</th>
                                    <th>Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @php $counter = 1 @endphp <!-- Initialize a counter variable -->
                                @foreach($unmatchedStudentIds as $studentId)
                                @php 
                                $student = App\Models\Studentdetails::find($studentId);
                                @endphp
                                <tr>
                                    <td>{{ $counter++ }}</td>
                                    <td>{{ $student->student_name }}</td>
                                    <td>{{ $student->student_age }}</td>
                                    <td>{{ $student->date_of_birth }}</td>
                                    <td>{{ $student->gender }}</td>
                                    <td>{{ $student->guardian_name }}</td>
                                    <td>{{ $student->communication_address }}</td>
                                    <td>{{ $student->contact_phone }}</td>
                                    <td>{{ $student->student_class }}</td>
                                    <td>{{ $student->student_std }}</td>
                                    <td>{{ $student->school_fees }}</td>
                                    <td>{{ $student->school_details }}</td>
                                    <td><img src="{{ asset($student->student_image) }}" alt="Student Image"
                                            width="100"></td>
                                    <td>
                                        <!-- Edit button -->
                                        <a href="{{ route('student.edit', $student->id) }}"
                                            class="btn btn-primary btn-sm">Edit</a>
                                        <!-- Delete button -->
                                        <form action="{{ route('student.destroy', $student->id) }}" method="POST"
                                            style="display: inline;">
                                            @csrf
                                            @method('DELETE')
                                            <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                                        </form>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
@endsection
