@extends('layouts.guru')
@section('content')
<x-slot name="header">
    <h2 class="font-semibold text-xl text-gray-800 leading-tight">
        {{ __('Edit jadwal') }}
    </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">


    <div class="card max-w-xl mx-auto p-6">
        <h2 class="text-xl font-bold text-primary mb-4">Edit Jadwal</h2>
        <form action="{{ route('jadwals.update', $jadwal) }}" method="POST">
            @csrf
            @method('PUT')
            <div class="mb-3">
                <label class="font-semibold">Kelas</label>
                <select name="kelas_id" class="form-control rounded" required>
                    <option value="">Pilih Kelas</option>
                    @foreach($kelas as $k)
                        <option value="{{ $k->id }}" {{ old('kelas_id', $jadwal->kelas_id)==$k->id?'selected':'' }}>{{ $k->nama_kelas }}</option>
                    @endforeach
                </select>
                @error('kelas_id')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
            </div>
            <div class="mb-3">
                <label class="font-semibold">Hari</label>
                <input type="text" name="hari" class="form-control rounded" value="{{ old('hari', $jadwal->hari) }}" required>
                @error('hari')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
            </div>
            <div class="mb-3">
                <label class="font-semibold">Jam Pelajaran</label>
                <input type="text" name="jam_pelajaran" class="form-control rounded" value="{{ old('jam_pelajaran', $jadwal->jam_pelajaran) }}" required>
                @error('jam_pelajaran')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
            </div>
            <div class="mb-3">
                <label class="font-semibold">Mata Pelajaran</label>
                <select name="mata_pelajaran_id" class="form-control rounded" required>
                    <option value="">Pilih Mapel</option>
                    @foreach($mapels as $m)
                        <option value="{{ $m->id }}" {{ old('mata_pelajaran_id', $jadwal->mata_pelajaran_id)==$m->id?'selected':'' }}>{{ $m->nama_mapel }}</option>
                    @endforeach
                </select>
                @error('mata_pelajaran_id')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
            </div>
            <div class="flex gap-2 mt-4">
                <button type="submit" class="btn-primary">Update</button>
                <a href="{{ route('jadwals.index') }}" class="btn-accent">Kembali</a>
            </div>
        </form>
    
            
</div>
@endsection 
