@extends('layouts.base')
@section('menu')
    @include('admin.menu')
@endsection
@section('content')

<section class="demandes-details bg-light py-5">
    <div class="container">
        <!-- Header -->
        <div class="header d-flex justify-content-between align-items-center mb-4">
            <h1 class="text-primary">Liste des étudiants</h1>
        </div>

          <!-- Barre de Recherche -->
          <form method="GET" action="{{ route('admin.show-etudiant') }}" class="mb-4" id="search-form">
                      <div class="row">
                          <div class="col-md-6">
                              <input 
                                  type="text" 
                                  name="query" 
                                  class="form-control" 
                                  placeholder="Rechercher..." 
                                  value="{{ request('query') }}" 
                              />
                          </div>
                          <div class="col-md-2">
                              <button type="submit" class="btn btn-primary">Rechercher</button>
                          </div>
                      </div>
                  </form>
                  @if(request('query')  )
                        <div class="alert alert-warning">
                            Aucun résultat trouvé pour "{{ request('query') }}".
                        </div>
                    @endif

        <!-- Liste des demandes d'inscription -->
        <div class="card shadow-sm">
            <div class="card-body">
                <hr>

                <!-- Table des utilisateurs -->
                <table class="table table-bordered">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Nom et prénoms de l'étudiants'</th>
                            <th>Date de l'inscription</th>
                            <th>Email</th>
                            <th>Déja soutenue ou non</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>
                        @php
                            $i = 1;

                        @endphp
                        @foreach ($students as $student)

                            <tr>
                                <td> {{$i}} </td>
                                <td> {{$student->nom . ' ' . $student->prenom}} </td>
                                <td>{{$student->date_nais}}</td>
                                <td> {{$student->email}}	</td>
                                <td>
                                    <span class="" >
                                        {{ $status[$student->matricule] }}
                                    </span>
                                </td>
                                <td>
                                        <a href="{{ route('admin.show-details-etudiant', $student->matricule) }}" class="btn btn-info btn-sm">
                                            Voir Détails
                                        </a>
                                </td>
                            </tr>

                            @php
                                $i++;
                            @endphp
                        @endforeach
                    </tbody>
                </table>


            </div>
        </div>
    </div>
</section>
@endsection
