@extends('layout.main')

@section('content')
    <div class="content-wrapper p-3">
        <div class="container-fluid">
            <h2>Daftar Produk</h2>
            <a href="{{ route('products.create') }}" class="btn btn-primary mb-3">Tambah Produk</a>
            <table class="table table-bordered">
                <thead>
                    <tr>
                        <th>Nama</th>
                        <th>Harga</th>
                        <th>Brand</th>
                        <th>Kategori</th>
                        <th>Gender</th>
                        <th>Deskripsi</th>
                        <th>Gambar</th>
                        <th>Aksi</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($products as $p)
                        <tr>
                            <td>{{ $p->name }}</td>
                            <td>Rp {{ $p->harga }}</td>
                            <td>{{ $p->brand }}</td>
                            <td>{{ $p->category }}</td>
                            <td>{{ $p->gender }}</td>
                            <td>{{ $p->deskripsi }}</td>
                            <td><img src="{{ asset('storage/' . $p->image) }}" width="100"></td>
                            <td>
                                <a href="{{ route('products.edit', $p->id) }}" class="btn btn-warning btn-sm">Edit</a>
                                <form action="{{ route('products.destroy', $p->id) }}" method="POST"
                                    style="display:inline-block;">
                                    @csrf @method('DELETE')
                                    <button class="btn btn-danger btn-sm"
                                        onclick="return confirm('Yakin ingin menghapus?')">Hapus</button>
                                </form>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
    </div>
@endsection
