Я следовал инструкциям, чтобы создать laravel корзину https://www.youtube.com/watch?v=Jzi6aLKVw-A&list=PLEhEHUEU3x5oPTli631ZX9cxl6cU_sDaR&index=3 и composer https://github.com/hardevine/LaravelShoppingcart Я хочу, чтобы кнопка выбора размера продукта
CartController. php
public function store(Request $request)
{
$duplicates = Cart::search(function ($cartItem, $rowId) use ($request) {
return $cartItem->id === $request->id;
});
if ($duplicates->isNotEmpty()) {
return redirect()->route('cart.index')->with('success_message', 'Item is already in your cart!');
}
Cart::add($request->id, $request->name, 1, $request->price, $request->data)->associate('App\Product');
return redirect()->route('cart.index')->with('success_message', 'Item was added to your cart!');
}
Product.blade. php
<h1 class="topic">{{ $product->name}}</h1>
<h4>{{ $product->price }}</h4>
<div class="size-b">
<div class="title">
<h5>Trousers</h5>
</div>
<form action="{{ route('cart.store') }}" method="POST">
{{ csrf_field() }}
<input type="hidden" name="id" value="{{ $product->id }}" >
<input type="hidden" name="name" value="{{ $product->name }}" >
<input type="hidden" name="price" value="{{ $product->price }}" >
<div class="btn-group" role="group" aria-label="Basic">
<button> <input type="checkbox" name="data" value="S" class="btn btn-secondary"><span>S</span></button>
<button><input type="checkbox" name="data" value="M" class="btn btn-secondary">M</button>
<button><input type="checkbox" name="data" value="L" class="btn btn-secondary">L</button>
<button> <input type="checkbox" name="data" value="XL" class="btn btn-secondary">XL</button>
</div>
<button type="submit" class="btn btn-secondary">ซื้อสินค้า</button>
</form>
cart.blade. php
@if (Cart::count() >0 )
<h4>{{ Cart::count() }}Item(s) in cart</h4>
<div class="table-cart-destop">
@foreach (Cart::content() as $item)
<div class="row">
<div class="col-lg">
<div class="remove">
<form action="{{ route('cart.destroy', $item->rowId) }}" method="POST">
{{ csrf_field() }}
{{ method_field('DELETE') }}
<button type="submit" class="btn btn-secondary">X</button>
</form>
</div>
</div>
<div class="col-lg-2">
<div class="image-border">
<img src="{{ $item->model->photo1}}" class="img-cart" alt="product-cart">
</div>
</div>
<div class="col-lg-5">
<div class="content">
<h4>{{ $item->model->name}}</h4>
<p>{{ $item->model->details}}</p>
</div>
</div>
<div class="col-lg">
<p class="size">size {{ $item->model->data }} </p>
</div>
<div class="col-lg">
<div class="quality">
<form action="">
<div class="form-row align-items-center">
<div class="col-auto my-1">
<select class="custom-select mr-sm-2" id="inlineFormCustomSelect">
<option selected>1</option>
<option value="1">2</option>
<option value="2">3</option>
<option value="3">4</option>
<option value="3">5</option>
</select>
</div>
</div>
</form>
</div>
</div>
<div class="col-lg">
<p class="size">{{ $item->data}}฿</p>
</div>
</div>
@endforeach
<div class="tatal">
<p>ยอดชำระเงินทั้งหมด</p>
<p class="price-tatal">{{ Cart::subtotal() }}฿</p>
</div>
<div class="buy-now">
<a href="{{ route('checkout.index') }}">
<button type="submit" class=" btn btn-secondary">สั่งซื้อสินค้า</button>
</a>
</div>
Я пытаюсь дд ($ request-> all ());
пробег php ремесленный сервиз -> размер товара (не показывать)