pai-sklep/resources/views/cart.blade.php
2021-12-15 18:56:52 +01:00

43 lines
1.6 KiB
PHP

@push('head')
<link rel="stylesheet" href="{{ mix("css/user.css") }}">
@endpush
@extends('layouts.app')
@section('title', "Sklep")
@section('main')
<div>
<h2>Your cart:</h2>
<div>
<div class="cart-items">
@foreach($user->cart as $product)
{{-- dd($product->pivot->quantity) --}}
<div class="cart-item">
<x-product :product="$product" />
<form method="POST" action="{{route("addToCart",$product)}}">
<input type="number" value="{{ $product->pivot->quantity }}" name="quantity">
<button type="submit"> Zatwierdź </button>
@csrf
</form>
<form class="remove-cart-form" action="{{ route("removeFromCart", $product) }}" method="post">
@csrf
<button type="submit"> Remove from cart </button>
</form>
</div>
@endforeach()
</div>
<form action="{{ route("order.create") }}" method="post">
@csrf
@foreach($user->cart as $product)
<input type="hidden" name="products[{{ $loop->index }}]" value="{{ $product->uuid }}">
<input type="hidden" name="product_quantities[{{ $loop->index }}]" value="{{ $product->pivot->quantity }}">
@endforeach()
<button type="submit"> Order </button>
</form>
</div>
</div>
@endsection()