@foreach ($pelanggarans as $data)
    <div class="modal fade" id="editModal_{{ $data->id_pelanggaran }}" tabindex="-1"
        aria-labelledby="editModalLabel_{{ $data->id_pelanggaran }}" aria-hidden="true">
        <div class="modal-dialog">

            <div class="modal-content">
                <div class="modal-header">
                    <h1 class="modal-title fs-5 font-bold" id="editModalLabel_{{ $data->id_pelanggaran }}">EDIT DATA
                        PELANGGARAN</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('pelanggaran.update', $data->id_pelanggaran) }}"
                        enctype="multipart/form-data" class="mt-6 space-y-6">
                        @csrf
                        @method('PATCH')

                        <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 WALI KELAS" />
                            <select id="id_guru" name="id_guru" class="block rounded-lg w-full" required>
                                <option value="">Pilih Wali Kelas</option>
                                @foreach ($guru as $item)
                                    <option value="{{ old('id_guru', $item->id_guru) }}" selected>{{ $item->nama_guru }}
                                    </option>
                                @endforeach
                            </select>
                        </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="{{ old('id_siswa', $siswa->id_siswa) }}" selected>
                                    {{ $siswa->nama_siswa }}</option>
                            @endforeach
                        </select>

                        <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
                            $points = App\Models\PointPelanggaran::all();
                        @endphp

                        <div class="max-w-xl">
                            <x-input-label for="id_point_pelanggaran" value="JENIS PELANGGARAN" />
                            <x-select-input id="id_point_pelanggaran" name="id_point_pelanggaran"
                                class="mt-1 block w-full" required>
                                <option value="">Pilih Wali Kelas</option>
                                @foreach ($points as $poin)
                                    <option value="{{ $poin->id_point_pelanggaran }}"
                                        {{ old('id_point_pelanggaran', $data->id_point_pelanggaran) == $poin->id_point_pelanggaran ? 'selected' : '' }}>
                                        {{ $poin->jenis_pelanggaran }} - {{ $poin->point }}
                                    </option>
                                @endforeach
                            </x-select-input>
                            <x-input-error class="mt-2" :messages="$errors->get('id_point_pelanggaran')" />
                        </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>
                </div>
            </div>
        </div>
    </div>
@endforeach
