<x-admin.layout title="Products">
    <div class="grid two">
        <div class="card">
            <h2>Create Product</h2>
            <form method="post" action="{{ route('admin.products.store') }}">
                @csrf
                <label>Slug</label><input name="slug" required placeholder="wordpress-plugin">
                <label>Name</label><input name="name" required>
                <label>Status</label><select name="status"><option>active</option><option>inactive</option><option>archived</option></select>
                <button type="submit">Create</button>
            </form>
        </div>
        <div class="card">
            <h2>Products</h2>
            <div class="table-wrap">
                <table><thead><tr><th>Name</th><th>Slug</th><th>Status</th><th>ID</th><th>Actions</th></tr></thead><tbody>
                    @foreach ($products as $product)
                        <tr>
                            <td colspan="5">
                                <form method="post" action="{{ route('admin.products.update', $product) }}" class="admin-inline-form">
                                    @csrf
                                    @method('PATCH')
                                    <input name="name" value="{{ $product->name }}" required>
                                    <code>{{ $product->slug }}</code>
                                    <select name="status">
                                        @foreach (['active', 'inactive', 'archived'] as $status)
                                            <option value="{{ $status }}" @selected($product->status === $status)>{{ $status }}</option>
                                        @endforeach
                                    </select>
                                    <code>{{ $product->id }}</code>
                                    <button type="submit">Save</button>
                                </form>
                                <form method="post" action="{{ route('admin.products.destroy', $product) }}" onsubmit="return confirm('Delete product?')">
                                    @csrf
                                    @method('DELETE')
                                    <button class="button danger" type="submit">Delete</button>
                                </form>
                            </td>
                        </tr>
                    @endforeach
                </tbody></table>
            </div>
            {{ $products->links() }}
        </div>
    </div>
</x-admin.layout>
