dimanche 15 août 2021

Undefined variabel : shop view at foreach list item shop

Here this is the error

Here this is the error

====

cart.blade.php I'm confused to make the page go directly to the shopping list. the error here says the shop variable is not defined in the loop to display items that have been added to the cart. but the data is already entered into the database

<div class="container">
    <div class="row mb-5">
        <form class="col-md-12" method="post">
            <div class="site-blocks-table">
                <table class="table table-bordered">

                    <thead>
                         <tr>
                            <th class="product-thumbnail">Image</th>
                            <th class="product-name">Product</th>
                            <th class="product-price">Price</th>
                            <th class="product-quantity">Quantity</th>
                            <th class="product-total">Total</th>
                          </tr>
                    </thead>
                    <tbody>
                    @foreach( $shop as $customer )
                    <tr>
                        <th class ="row"></th>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td>
                        <a href="#" class="btn btn-primary btn-sm">X</a>
                        </td>
                    </tr>
                    @endforeach
                    </tbody>
                </table>
            </div>
        </form>
    </div>

    <div class="row">
        <div class="col-md-6">
            <div class="row mb-5">
                <div class="col-md-6 mb-3 mb-md-0">
                    <button class="btn btn-primary btn-sm btn-block">Update Cart</button>
                </div>
                <div class="col-md-6">
                    <button class="btn btn-outline-primary btn-sm btn-block">Continue Shopping</button>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <label class="text-black h4" for="coupon">Coupon</label>
                    <p>Enter your coupon code if you have one.</p>
                </div>
                <div class="col-md-8 mb-3 mb-md-0">
                    <input type="text" class="form-control py-3" id="coupon" placeholder="Coupon Code">
                </div>
                <div class="col-md-4">
                    <button class="btn btn-primary btn-sm">Apply Coupon</button>
                </div>
            </div>
        </div>
        <div class="col-md-6 pl-5">
            <div class="row justify-content-end">
                <div class="col-md-7">
                    <div class="row">
                        <div class="col-md-12 text-right border-bottom mb-5">
                            <h3 class="text-black h4 text-uppercase">Cart Totals</h3>
                        </div>
                    </div>
                    <div class="row mb-3">
                        <div class="col-md-6">
                            <span class="text-black">Subtotal</span>
                        </div>
                        <div class="col-md-6 text-right">
                            <strong class="text-black"></strong>
                        </div>
                    </div>
                    <div class="row mb-5">
                        <div class="col-md-6">
                            <span class="text-black">Total</span>
                        </div>
                        <div class="col-md-6 text-right">
                            <strong class="text-black"></strong>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-md-12">
                            <button class="btn btn-primary btn-lg py-3 btn-block"
                                onclick="window.location='checkout.html'">Proceed To Checkout</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

cart contorller

public function store(Request $request) {

    $user = Auth::user();
    $ac = new addcart();
    $ac->product = 'tanktop';
    // $ac->product = !empty($request->product) ? $request->product : 'default value';
    $ac->product_price = 500.000;
    $ac->item_model = $request->model;
    $ac->quantity = $request->qty;

    $ac->save();
    // $shop_id = $ac->id;
    return redirect('/cart');
}


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/37KsMxS
via IFTTT

Aucun commentaire:

Enregistrer un commentaire