<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Daftar mata pelajaran') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6">


    
        <h2 class="text-xl font-bold text-primary mb-4">Daftar Mata Pelajaran</h2>
        <a href="{{ route('mata_pelajarans.create') }}" class="btn-primary">Tambah Mata Pelajaran</a>
        @if(session('success'))
            <div class="alert-success mb-4">{{ session('success') }}</div>
        @endif
        <div class="overflow-x-auto">
            <table class="table w-full border rounded-lg overflow-hidden">
                <thead>
                    <tr class="table-header">
                        <th class="px-3 py-2">No</th>
                        <th class="px-3 py-2">Kode Mapel</th>
                        <th class="px-3 py-2">Nama Mapel</th>
                        <th class="px-3 py-2">Action</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($mataPelajarans as $i => $mapel)
                    <tr class="table-row">
                        <td class="px-3 py-2">{{ $i+1 }}</td>
                        <td class="px-3 py-2">{{ $mapel->kode_mapel }}</td>
                        <td class="px-3 py-2">{{ $mapel->nama_mapel }}</td>
                        <td class="px-3 py-2 space-x-1">
                            <a href="{{ route('mata_pelajarans.edit', $mapel) }}" class="btn-accent btn-sm">Edit</a>
                            <form action="{{ route('mata_pelajarans.destroy', $mapel) }}" method="POST" style="display:inline-block">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn-primary btn-sm" onclick="return confirm('Yakin hapus?')">Delete</button>
                            </form>
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        

                
    </div>
</x-app-layout> 
