@extends('layouts.main')

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

@section('content')
<div class="container pt-5 mb-5">
    <div class="row gy-4 shadow mb-4 bg-body-tertiary rounded">
        <h3 class="mb-0">Alternatif Makanan</h3>
        <p class="text-success mt-0">Detail Alternatif Makanan / {{ $makanan->nama }}</p>
    </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>
            <div class="row">
                <div class="col-md-6">
                    <div class="form-group">
                        <label for="kode">Kode</label>
                        <input type="text" class="form-control" id="kode" value="{{ $makanan->kode }}" readonly>
                    </div>
                    <div class="form-group">
                        <label for="alternatif">Nama Alternatif</label>
                        <input type="text" class="form-control" id="alternatif" value="{{ $makanan->alternatif }}" readonly>
                    </div>
                    @foreach($makanan->kriteria_makanan as $value)
                    <div class="form-group">
                        <label for="{{ $value->kriteria->nama }}">{{ $value->kriteria->nama }}</label>
                        <input type="text" class="form-control" id="{{ $value->kriteria->nama }}" value="{{ $value->nilai }}" readonly>
                    </div>
                    @endforeach
                </div>
                <div class="col-md-6">

                    {{-- pagi --}}
                    <div class="row">
                        <div class="col-sm-12 pb-3 pt-3">
                            <button type="button" class="font-sm text-white btn btn-success" data-toggle="modal" data-target="#pagi"><i class='bx bx-plus'></i>
                                Tambah
                            </button>
                            {{-- modal tambah makanan pagi --}}
                            <div class="modal fade" id="pagi" tabindex="-1" role="dialog" aria-labelledby="pagi" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" id="pagi">Pagi</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                    </button>
                                    </div>
                                    <form action="{{ route('makanan.tambahdetailmakanan', $makanan->id) }}" method="post">
                                        @csrf
                                        <div class="modal-body">
                                            <div class="form-group">
                                                <label for="nama_makanan">Nama Makanan</label>
                                                <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="">
                                                @error('nama_makanan')
                                                    <span class="invalid-feedback" role="alert">
                                                        {{ $message }}
                                                    </span>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label for="berat">Berat</label>
                                                <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="">
                                                @error('berat')
                                                    <span class="invalid-feedback" role="alert">
                                                        {{ $message }}
                                                    </span>
                                                @enderror
                                            </div>
                                            <div class="form-group">
                                                <label for="kalori">Kalori</label>
                                                <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="">
                                                @error('kalori')
                                                    <span class="invalid-feedback" role="alert">
                                                        {{ $message }}
                                                    </span>
                                                @enderror
                                            </div>
                                            <div class="form-group" hidden>
                                                <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                            </div>
                                            <div class="form-group" hidden>
                                                <input type="text" name="waktu" value="Pagi">
                                            </div>
                                        </div>
                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                            <button type="submit" class="btn btn-success">Simpan</button>
                                        </div>
                                    </form>
                                </div>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                            <table class="table table-hover table-stripped border-right border-bottom border-left table-bordered">
                                <thead>
                                    <tr>
                                        <th>Pagi</th>
                                        <th>Berat</th>
                                        <th>Kalori</th>
                                        <th>Aksi</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach ($detailMakanan as $detail)
                                    @if ($detail->waktu == 'Pagi')
                                    <tr>
                                        <td>{{ $detail->nama_makanan }}</td>
                                        <td>{{ $detail->berat }}</td>
                                        <td>{{ $detail->kalori }}</td>
                                        <td>
                                            <a class="btn btn-warning btn-xs text-white" data-toggle="modal" data-target="#pagiedit{{ $detail->id }}"><i class='bx bx-edit-alt'></i>
                                                Edit
                                            </a>
                                            {{-- edit modal makanan pagi --}}
                                            <div class="modal fade" id="pagiedit{{ $detail->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                <div class="modal-dialog" role="document">
                                                  <div class="modal-content">
                                                    <div class="modal-header">
                                                      <h5 class="modal-title" id="exampleModalLabel">Pagi</h5>
                                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                      </button>
                                                    </div>
                                                    <form action="{{ route('makanan.updatedetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" method="post">
                                                        @csrf
                                                        <div class="modal-body">
                                                        <div class="form-group">
                                                            <label for="nama_makanan">Nama Makanan</label>
                                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="{{ $detail->nama_makanan }}">
                                                            @error('nama_makanan')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="berat">Berat</label>
                                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="{{ $detail->berat }}">
                                                            @error('berat')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="kalori">Kalori</label>
                                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="{{ $detail->kalori }}">
                                                            @error('kalori')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="waktu" value="Pagi">
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                                      <button type="submit" class="btn btn-success">Simpan</button>
                                                    </div>
                                                    </form>
                                                  </div>
                                                </div>
                                            </div>
                                            <a id="delete" href="{{ route('makanan.destroydetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" class="btn btn-danger btn-xs" onclick="notificationBeforeDelete(event, this)"><i class='bx bx-trash'></i>
                                                Delete
                                            </a>
                                        </td>
                                    </tr>
                                    @endif
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>

                    {{-- snack pagi --}}
                    <div class="row">
                        <div class="col-sm-12 pb-3 pt-3">
                            <button type="button" class="font-sm text-white btn btn-success" data-toggle="modal" data-target="#snackpagi"><i class='bx bx-plus'></i>
                                Tambah
                              </button>
                            {{-- modal tambah snack pagi --}}
                            <div class="modal fade" id="snackpagi" tabindex="-1" role="dialog" aria-labelledby="snackpagi" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <h5 class="modal-title" id="snackpagi">Snack Pagi</h5>
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                      </button>
                                    </div>
                                    <form action="{{ route('makanan.tambahdetailmakanan', $makanan->id) }}" method="post">
                                        @csrf
                                        <div class="modal-body">
                                        <div class="form-group">
                                            <label for="nama_makanan">Nama Makanan</label>
                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="">
                                            @error('nama_makanan')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="berat">Berat</label>
                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="">
                                            @error('berat')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="kalori">Kalori</label>
                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="">
                                            @error('kalori')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="waktu" value="Snack Pagi">
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                      <button type="submit" class="btn btn-success">Simpan</button>
                                    </div>
                                    </form>
                                  </div>
                                </div>
                              </div>
                              
                        </div>
                        <div class="col-md-12">
                            <table class="table table-hover table-stripped border-right border-bottom border-left table-bordered">
                                <thead>
                                    <tr>
                                        <th>Snack Pagi</th>
                                        <th>Berat</th>
                                        <th>Kalori</th>
                                        <th>Aksi</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach ($detailMakanan as $detail)
                                    @if ($detail->waktu == 'Snack Pagi')
                                    <tr>
                                        <td>{{ $detail->nama_makanan }}</td>
                                        <td>{{ $detail->berat }}</td>
                                        <td>{{ $detail->kalori }}</td>
                                        <td>
                                            <a class="btn btn-warning btn-xs text-white" data-toggle="modal" data-target="#snackpagiedit{{ $detail->id }}"><i class='bx bx-edit-alt'></i>
                                                Edit
                                            </a>
                                            {{-- edit modal snack pagi --}}
                                            <div class="modal fade" id="snackpagiedit{{ $detail->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                <div class="modal-dialog" role="document">
                                                  <div class="modal-content">
                                                    <div class="modal-header">
                                                      <h5 class="modal-title" id="exampleModalLabel">Snack Pagi</h5>
                                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                      </button>
                                                    </div>
                                                    <form action="{{ route('makanan.updatedetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" method="post">
                                                        @csrf
                                                        <div class="modal-body">
                                                        <div class="form-group">
                                                            <label for="nama_makanan">Nama Makanan</label>
                                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="{{ $detail->nama_makanan }}">
                                                            @error('nama_makanan')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="berat">Berat</label>
                                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="{{ $detail->berat }}">
                                                            @error('berat')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="kalori">Kalori</label>
                                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="{{ $detail->kalori }}">
                                                            @error('kalori')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="waktu" value="Snack Pagi">
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                                      <button type="submit" class="btn btn-success">Simpan</button>
                                                    </div>
                                                    </form>
                                                  </div>
                                                </div>
                                            </div>
                                            <a id="delete" href="{{ route('makanan.destroydetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" class="btn btn-danger btn-xs" onclick="notificationBeforeDelete(event, this)"><i class='bx bx-trash'></i>
                                                Delete
                                            </a>
                                        </td>
                                    </tr>
                                    @endif
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>

                    {{-- siang --}}
                    <div class="row">
                        <div class="col-sm-12 pb-3 pt-3">
                            <button type="button" class="font-sm text-white btn btn-success" data-toggle="modal" data-target="#siang"><i class='bx bx-plus'></i>
                                Tambah
                              </button>
                            {{-- modal tambah siang --}}
                            <div class="modal fade" id="siang" tabindex="-1" role="dialog" aria-labelledby="siang" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <h5 class="modal-title" id="snackpagi">Siang</h5>
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                      </button>
                                    </div>
                                    <form action="{{ route('makanan.tambahdetailmakanan', $makanan->id) }}" method="post">
                                        @csrf
                                        <div class="modal-body">
                                        <div class="form-group">
                                            <label for="nama_makanan">Nama Makanan</label>
                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="">
                                            @error('nama_makanan')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="berat">Berat</label>
                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="">
                                            @error('berat')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="kalori">Kalori</label>
                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="">
                                            @error('kalori')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="waktu" value="Siang">
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                      <button type="submit" class="btn btn-success">Simpan</button>
                                    </div>
                                    </form>
                                  </div>
                                </div>
                              </div>
                              
                        </div>
                        <div class="col-md-12">
                            <table class="table table-hover table-stripped border-right border-bottom border-left table-bordered">
                                <thead>
                                    <tr>
                                        <th>Siang</th>
                                        <th>Berat</th>
                                        <th>Kalori</th>
                                        <th>Aksi</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach ($detailMakanan as $detail)
                                    @if ($detail->waktu == 'Siang')
                                    <tr>
                                        <td>{{ $detail->nama_makanan }}</td>
                                        <td>{{ $detail->berat }}</td>
                                        <td>{{ $detail->kalori }}</td>
                                        <td>
                                            <a class="btn btn-warning btn-xs text-white" data-toggle="modal" data-target="#siang{{ $detail->id }}"><i class='bx bx-edit-alt'></i>
                                                Edit
                                            </a>
                                            {{-- edit modal snack pagi --}}
                                            <div class="modal fade" id="siang{{ $detail->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                <div class="modal-dialog" role="document">
                                                  <div class="modal-content">
                                                    <div class="modal-header">
                                                      <h5 class="modal-title" id="exampleModalLabel">Siang</h5>
                                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                      </button>
                                                    </div>
                                                    <form action="{{ route('makanan.updatedetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" method="post">
                                                        @csrf
                                                        <div class="modal-body">
                                                        <div class="form-group">
                                                            <label for="nama_makanan">Nama Makanan</label>
                                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="{{ $detail->nama_makanan }}">
                                                            @error('nama_makanan')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="berat">Berat</label>
                                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="{{ $detail->berat }}">
                                                            @error('berat')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="kalori">Kalori</label>
                                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="{{ $detail->kalori }}">
                                                            @error('kalori')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="waktu" value="Siang">
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                                      <button type="submit" class="btn btn-success">Simpan</button>
                                                    </div>
                                                    </form>
                                                  </div>
                                                </div>
                                            </div>
                                            <a id="delete" href="{{ route('makanan.destroydetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" class="btn btn-danger btn-xs" onclick="notificationBeforeDelete(event, this)"><i class='bx bx-trash'></i>
                                                Delete
                                            </a>
                                        </td>
                                    </tr>
                                    @endif
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>

                    {{-- snack siang --}}
                    <div class="row">
                        <div class="col-sm-12 pb-3 pt-3">
                            <button type="button" class="font-sm text-white btn btn-success" data-toggle="modal" data-target="#snacksiang"><i class='bx bx-plus'></i>
                                Tambah
                              </button>
                            {{-- modal tambah snack snacksiang --}}
                            <div class="modal fade" id="snacksiang" tabindex="-1" role="dialog" aria-labelledby="snacksiang" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <h5 class="modal-title" id="snackpagi">Siang</h5>
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                      </button>
                                    </div>
                                    <form action="{{ route('makanan.tambahdetailmakanan', $makanan->id) }}" method="post">
                                        @csrf
                                        <div class="modal-body">
                                        <div class="form-group">
                                            <label for="nama_makanan">Nama Makanan</label>
                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="">
                                            @error('nama_makanan')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="berat">Berat</label>
                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="">
                                            @error('berat')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="kalori">Kalori</label>
                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="">
                                            @error('kalori')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="waktu" value="Snack Siang">
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                      <button type="submit" class="btn btn-success">Simpan</button>
                                    </div>
                                    </form>
                                  </div>
                                </div>
                              </div>
                              
                        </div>
                        <div class="col-md-12">
                            <table class="table table-hover table-stripped border-right border-bottom border-left table-bordered">
                                <thead>
                                    <tr>
                                        <th>Snack Siang</th>
                                        <th>Berat</th>
                                        <th>Kalori</th>
                                        <th>Aksi</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach ($detailMakanan as $detail)
                                    @if ($detail->waktu == 'Snack Siang')
                                    <tr>
                                        <td>{{ $detail->nama_makanan }}</td>
                                        <td>{{ $detail->berat }}</td>
                                        <td>{{ $detail->kalori }}</td>
                                        <td>
                                            <a class="btn btn-warning btn-xs text-white" data-toggle="modal" data-target="#snacksiang{{ $detail->id }}"><i class='bx bx-edit-alt'></i>
                                                Edit
                                            </a>
                                            {{-- edit modal snack snacksiang --}}
                                            <div class="modal fade" id="snacksiang{{ $detail->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                <div class="modal-dialog" role="document">
                                                  <div class="modal-content">
                                                    <div class="modal-header">
                                                      <h5 class="modal-title" id="exampleModalLabel">Siang</h5>
                                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                      </button>
                                                    </div>
                                                    <form action="{{ route('makanan.updatedetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" method="post">
                                                        @csrf
                                                        <div class="modal-body">
                                                        <div class="form-group">
                                                            <label for="nama_makanan">Nama Makanan</label>
                                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="{{ $detail->nama_makanan }}">
                                                            @error('nama_makanan')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="berat">Berat</label>
                                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="{{ $detail->berat }}">
                                                            @error('berat')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="kalori">Kalori</label>
                                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="{{ $detail->kalori }}">
                                                            @error('kalori')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="waktu" value="Snack Siang">
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                                      <button type="submit" class="btn btn-success">Simpan</button>
                                                    </div>
                                                    </form>
                                                  </div>
                                                </div>
                                            </div>
                                            <a id="delete" href="{{ route('makanan.destroydetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" class="btn btn-danger btn-xs" onclick="notificationBeforeDelete(event, this)"><i class='bx bx-trash'></i>
                                                Delete
                                            </a>
                                        </td>
                                    </tr>
                                    @endif
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>

                    {{-- malam --}}
                    <div class="row">
                        <div class="col-sm-12 pb-3 pt-3">
                            <button type="button" class="font-sm text-white btn btn-success" data-toggle="modal" data-target="#malam"><i class='bx bx-plus'></i>
                                Tambah
                              </button>
                            {{-- modal tambah malam --}}
                            <div class="modal fade" id="malam" tabindex="-1" role="dialog" aria-labelledby="malam" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                  <div class="modal-content">
                                    <div class="modal-header">
                                      <h5 class="modal-title" id="malam">Malam</h5>
                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                      </button>
                                    </div>
                                    <form action="{{ route('makanan.tambahdetailmakanan', $makanan->id) }}" method="post">
                                        @csrf
                                        <div class="modal-body">
                                        <div class="form-group">
                                            <label for="nama_makanan">Nama Makanan</label>
                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="">
                                            @error('nama_makanan')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="berat">Berat</label>
                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="">
                                            @error('berat')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group">
                                            <label for="kalori">Kalori</label>
                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="">
                                            @error('kalori')
                                                <span class="invalid-feedback" role="alert">
                                                    {{ $message }}
                                                </span>
                                            @enderror
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                        </div>
                                        <div class="form-group" hidden>
                                            <input type="text" name="waktu" value="Malam">
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                      <button type="submit" class="btn btn-success">Simpan</button>
                                    </div>
                                    </form>
                                  </div>
                                </div>
                              </div>
                              
                        </div>
                        <div class="col-md-12">
                            <table class="table table-hover table-stripped border-right border-bottom border-left table-bordered">
                                <thead>
                                    <tr>
                                        <th>Malam</th>
                                        <th>Berat</th>
                                        <th>Kalori</th>
                                        <th>Aksi</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    @foreach ($detailMakanan as $detail)
                                    @if ($detail->waktu == 'Malam')
                                    <tr>
                                        <td>{{ $detail->nama_makanan }}</td>
                                        <td>{{ $detail->berat }}</td>
                                        <td>{{ $detail->kalori }}</td>
                                        <td>
                                            <a class="btn btn-warning btn-xs text-white" data-toggle="modal" data-target="#malam{{ $detail->id }}"><i class='bx bx-edit-alt'></i>
                                                Edit
                                            </a>
                                            {{-- edit modal snack pagi --}}
                                            <div class="modal fade" id="malam{{ $detail->id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                                                <div class="modal-dialog" role="document">
                                                  <div class="modal-content">
                                                    <div class="modal-header">
                                                      <h5 class="modal-title" id="exampleModalLabel">Malam</h5>
                                                      <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                      </button>
                                                    </div>
                                                    <form action="{{ route('makanan.updatedetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" method="post">
                                                        @csrf
                                                        <div class="modal-body">
                                                        <div class="form-group">
                                                            <label for="nama_makanan">Nama Makanan</label>
                                                            <input type="text" class="form-control @error('nama_makanan') is-invalid @enderror" id="nama_makanan" name="nama_makanan" value="{{ $detail->nama_makanan }}">
                                                            @error('nama_makanan')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="berat">Berat</label>
                                                            <input type="text" class="form-control @error('berat') is-invalid @enderror" id="berat" name="berat" value="{{ $detail->berat }}">
                                                            @error('berat')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group">
                                                            <label for="kalori">Kalori</label>
                                                            <input type="text" class="form-control @error('kalori') is-invalid @enderror" id="kalori" name="kalori" value="{{ $detail->kalori }}">
                                                            @error('kalori')
                                                                <span class="invalid-feedback" role="alert">
                                                                    {{ $message }}
                                                                </span>
                                                            @enderror
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="makanan_id" value="{{ $makanan->id }}">
                                                        </div>
                                                        <div class="form-group" hidden>
                                                            <input type="text" name="waktu" value="Malam">
                                                        </div>
                                                    </div>
                                                    <div class="modal-footer">
                                                      <button type="button" class="btn btn-danger" data-dismiss="modal">Kembali</button>
                                                      <button type="submit" class="btn btn-success">Simpan</button>
                                                    </div>
                                                    </form>
                                                  </div>
                                                </div>
                                            </div>
                                            <a id="delete" href="{{ route('makanan.destroydetailmakanan', ['id' => $detail->id,'idMakanan' => $makanan->id]) }}" class="btn btn-danger btn-xs" onclick="notificationBeforeDelete(event, this)"><i class='bx bx-trash'></i>
                                                Delete
                                            </a>
                                        </td>
                                    </tr>
                                    @endif
                                    @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>

                    {{-- total kalori --}}
                    <div class="row">
                        <div class="col-md-12">
                            <table class="table table-hover table-stripped border-right border-bottom border-left table-bordered">
                                <thead>
                                    <tr>
                                        <th>Total</th>
                                        <th>{{ $count }}</th>
                                    </tr>
                                </thead>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

@endsection
