@extends('layouts.admin')

@section('content')
    <div class="row">
      <div class="col-8">
        <div class="card">
          <div class="card-body">
            <div class="d-md-flex align-items-center">
              <div>
                <h4 class="card-title">Produk</h4>
              </div>
            </div>
            <form method="POST" action="{{ route('admin.product') }}" enctype="multipart/form-data">
                @csrf @method('PUT')
                <input type="hidden" name="id" value="{{ $product->id }}">
                <div class="mb-3">
                    <label for="name" class="form-label">Nama</label>
                    <input type="text" required value="{{ $product->name }}" name="name" class="form-control" id="name">
                </div>
                <div class="mb-3">
                    <label for="description" class="form-label">Deskripsi Produk</label>
                    <textarea name="description" id="description" cols="30" rows="10" class="form-control">{{ $product->description }}</textarea>
                </div>
                <div class="mb-3">
                    <label for="product_category_id" class="form-label">Kategori Produk</label>
                    <select name="product_category_id" id="product_category_id" class="form-control" required>
                      <option value="">Silahkan Pilih</option>
                      @foreach ($product_category as $item)
                        <option value="{{$item->id}}" @if ($product->product_category_id == $item->id)
                            selected
                        @endif>{{ $item->name }}</option>
                      @endforeach
                    </select>
                </div>
               <div class="mb-3 form-check">
                  <input type="checkbox" name="is_discount" @if ($product->is_discount == 1)
                      checked
                  @endif class="form-check-input" id="is_dicount">
                  <label class="form-check-label" for="checkbox">Diskon?</label>
                </div>
                <div class="mb-3">
                    <label for="discount_price" class="form-label">Harga Diskon</label>
                    <input type="number" name="discount_price" class="form-control" value="{{ $product->discount_price }}" id="discount_price">
                </div>
                 <div class="mb-3">
                    <label for="price" class="form-label">Harga</label>
                    <input type="number" required name="price" class="form-control" value="{{ $product->price }}" id="price">
                </div>
                <div class="mb-3">
                    <label for="image" class="form-label">Gambar</label>
                    <input type="file" name="image" class="form-control" id="image">
                </div>
                <div class="mb-3">
                    <label for="stock" class="form-label">Stok</label>
                    <input type="number" required name="stock" class="form-control" value="{{ $product->stock }}" id="stock">
                </div>
                <button type="submit" class="btn btn-primary rounded-2">Simpan</button>
            </form>
          </div>
        </div>
      </div>
    </div>
@endsection