@foreach($belajar as $data)
<div class="modal fade" id="exampleModal_{{$data->id_belajar}}" tabindex="-1" aria-labelledby="exampleModalLabel_{{$data->id_belajar}}" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h1 class="modal-title fs-5 font-bold" id="exampleModalLabel_{{$data->id_belajar}}">EDIT DATA BK-BELAJAR</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form method="post" action="{{ route('belajar.update', $data->id_belajar) }}" enctype="multipart/form-data" class="mt-6 space-y-6">
                    @csrf
                    @method('PATCH')
                    <div class="max-w-xl">
                        <x-input-label for="tanggal" value="TANGGAL" />
                        <x-text-input id="tanggal" type="date" name="tanggal" class="mt-1 block w-full" value="{{ old('tanggal', $data->tanggal)}}"
                            required />
                        <x-input-error class="mt-2" :messages="$errors->get('tanggal')" />
                    </div>

                    @php
                    $siswas = App\Models\Siswa::all();
                    @endphp
                    <x-input-label for="id_siswa" value="NAMA SISWA" />
                    <select id="id_siswa" name="id_siswa" class="mt-1 block w-full rounded-md" required>
                        <option value="">Pilih Siswa</option>
                        @foreach ($siswas as $siswa)
                        <option value="{{ $siswa->id_siswa }}"
                            {{ old('id_siswa', $data->id_siswa) == $siswa->id_siswa ? 'selected' : '' }}>
                            {{ $siswa->nama_siswa }}
                        </option>
                        @endforeach
                    </select>

                    <div class="max-w-xl">
                        <x-input-label for="permasalahan" value="PERMASALAHAN" />
                        <x-text-input id="permasalahan" type="text" name="permasalahan" class="mt-1 block w-full" value="{{ old('permasalahan', $data->permasalahan)}}" />
                        <x-input-error class="mt-2" :messages="$errors->get('permasalahan')" />
                    </div>
                    <div class="max-w-xl">
                        <x-input-label for="mapel" value="MAPEL" />
                        <x-text-input id="mapel" type="text" name="mapel" class="mt-1 block w-full" value="{{ old('mapel', $data->mapel)}}" />
                        <x-input-error class="mt-2" :messages="$errors->get('mapel')" />
                    </div>

                    <div class="max-w-xl">
                        @php
                        $guru = App\Models\Guru::where('jabatan', 'LIKE', '%Wali Kelas%')->get();
                        @endphp

                        <x-input-label for="id_guru" value="NAMA GURU MATAPELAJARAN" />
                        <select id="id_guru" name="id_guru" class="block rounded-lg w-full" required>
                            <option value="">Pilih Guru Matapelajaran</option>
                            @foreach ($guru as $item)
                            <option value="{{ $item->id_guru }}"
                                {{ old('id_guru', $data->id_guru) == $item->id_guru ? 'selected' : '' }}>
                                {{ $item->nama_guru }}
                            </option>
                            @endforeach
                        </select>
                        <x-input-error class="mt-2" :messages="$errors->get('id_guru')" />
                    </div>

                    <div class="max-w-xl">
                        <x-input-label for="keterangan" value="KETERANGAN" />
                        <x-text-input id="keterangan" type="text" name="keterangan" class="mt-1 block w-full" value="{{ old('keterangan', $data->keterangan)}}" />
                        <x-input-error class="mt-2" :messages="$errors->get('keterangan')" />
                    </div>
                    <div class="modal-footer">
                        <x-secondary-button tag="a" data-bs-dismiss="modal">Batal</x-secondary-button>
                        <x-primary-button name="save" value="true">Simpan</x-primary-button>
                    </div>
                </form>
                </form>
            </div>
        </div>
    </div>
</div>
@endforeach
@section('scripts')
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js"></script>
@endsection