@extends('layouts.main')

@section('title', $title = 'Edit Makanan Alternatif')

@section('content')
<div class="container pt-5 mb-5">
    <div class="row gy-4 shadow mb-4 bg-body-tertiary rounded">
        <h3 class="mb-4">Edit Makanan Alternatif</h3>
    </div>
    <div class="row gy-4">
        <div class="pt-3 card">
            <div class="row">
                <div class="col-sm-12 pb-3 pt-3">
                    <a href="{{ route('makanan.index') }}" class="font-sm btn btn-warning text-white"><i class='bx bx-chevron-left'></i> Kembali</a>
                </div>
            </div>
            <form action="{{ route('makanan.update',$makanan->id) }}" method="POST">
                @csrf
                <div class="row">
                    <div class="col-md-6">
                        <div class="form-group">
                            <label for="kode">Kode</label>
                            <input type="text" class="form-control @error('kode') is-invalid @enderror" id="kode" name="kode" value="{{ $makanan->kode }}">
                            @error('kode')
                                <span class="invalid-feedback" role="alert">
                                    {{ $message }}
                                </span>
                            @enderror
                        </div>
                        <div class="form-group">
                            <label for="nama_alternatif">Nama Alternatif</label>
                            <input type="text" class="form-control @error('nama_alternatif') is-invalid @enderror" id="nama_alternatif" name="alternatif" value="{{ $makanan->alternatif }}">
                            @error('nama_alternatif')
                                <span class="invalid-feedback" role="alert">
                                    {{ $message }}
                                </span>
                            @enderror
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="karbohidrat">Karbohidrat</label>
                                    <input type="text" class="form-control @error('karbohidrat') is-invalid @enderror" name="karbohidrat" id="karbohidrat" value="{{ $karbohidrat->nilai }}">
                                    @error('karbohidrat')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="karbohidrat_ket">Keterangan</label>
                                    <select class="form-select @error('karbohidrat_ket') is-invalid @enderror" name="karbohidrat_ket" id="karbohidrat_ket">
                                            <option value="1" {{ $karbohidrat->keterangan == 1 ? 'selected' : '' }}>Sangat sedikit</option>
                                            <option value="2" {{ $karbohidrat->keterangan == 2 ? 'selected' : '' }}>Sedikit</option>
                                            <option value="3" {{ $karbohidrat->keterangan == 3 ? 'selected' : '' }}>Cukup</option>
                                            <option value="4" {{ $karbohidrat->keterangan == 4 ? 'selected' : '' }}>Banyak</option>
                                            <option value="5" {{ $karbohidrat->keterangan == 5 ? 'selected' : '' }}>Sangat banyak</option>
                                    </select>
                                    @error('karbohidrat_ket')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                        </div>
                        
                    </div>
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="lemak">Lemak</label>
                                    <input type="text" class="form-control @error('lemak') is-invalid @enderror" name="lemak" id="lemak" value="{{ $lemak->nilai }}">
                                    @error('lemak')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="lemak_ket">Keterangan</label>
                                    <select class="form-select @error('lemak_ket') is-invalid @enderror" name="lemak_ket" id="lemak_ket">
                                            <option value="1" {{ $lemak->keterangan == 1 ? 'selected' : '' }}>Sangat sedikit</option>
                                            <option value="2" {{ $lemak->keterangan == 2 ? 'selected' : '' }}>Sedikit</option>
                                            <option value="3" {{ $lemak->keterangan == 3 ? 'selected' : '' }}>Cukup</option>
                                            <option value="4" {{ $lemak->keterangan == 4 ? 'selected' : '' }}>Banyak</option>
                                            <option value="5" {{ $lemak->keterangan == 5 ? 'selected' : '' }}>Sangat banyak</option>
                                    </select>
                                    @error('lemak_ket')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="protein">Protein</label>
                                    <input type="text" class="form-control @error('protein') is-invalid @enderror" id="protein" name="protein" value="{{ $protein->nilai }}">
                                    @error('protein')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="protein_ket">Keterangan</label>
                                    <select class="form-select @error('protein_ket') is-invalid @enderror" name="protein_ket" id="protein_ket">
                                            <option value="1" {{ $protein->keterangan == 1 ? 'selected' : '' }}>Sangat sedikit</option>
                                            <option value="2" {{ $protein->keterangan == 2 ? 'selected' : '' }}>Sedikit</option>
                                            <option value="3" {{ $protein->keterangan == 3 ? 'selected' : '' }}>Cukup</option>
                                            <option value="4" {{ $protein->keterangan == 4 ? 'selected' : '' }}>Banyak</option>
                                            <option value="5" {{ $protein->keterangan == 5 ? 'selected' : '' }}>Sangat banyak</option>
                                    </select>
                                    @error('protein_ket')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="serat">Serat</label>
                                    <input type="text" class="form-control @error('serat') is-invalid @enderror" name="serat" id="serat" value="{{ $serat->nilai }}">
                                    @error('serat')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label for="serat_ket">Keterangan</label>
                                    <select class="form-select @error('serat_ket') is-invalid @enderror" name="serat_ket" id="serat_ket">
                                            <option value="1" {{ $serat->keterangan == 1 ? 'selected' : '' }}>Sangat sedikit</option>
                                            <option value="2" {{ $serat->keterangan == 2 ? 'selected' : '' }}>Sedikit</option>
                                            <option value="3" {{ $serat->keterangan == 3 ? 'selected' : '' }}>Cukup</option>
                                            <option value="4" {{ $serat->keterangan == 4 ? 'selected' : '' }}>Banyak</option>
                                            <option value="5" {{ $serat->keterangan == 5 ? 'selected' : '' }}>Sangat banyak</option>
                                    </select>
                                    @error('serat_ket')
                                        <span class="invalid-feedback" role="alert">
                                            {{ $message }}
                                        </span>
                                    @enderror
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row mb-3">
                    <div class="text-end"> <!-- Menambahkan kelas text-end di sini -->
                        <button type="submit" class="btn btn-success"><i class='bx bx-save'></i>
                            Simpan</button>
                        <a href="{{ route('makanan.index') }}" class="btn btn-danger"><i class='bx bx-x'></i>
                            Batal</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
@endsection
