I'm trying to add products items into the shopping cart when I click to add to cart button but facing some error how to fix it error
please see this error Non-static method Gloudemans\Shoppingcart\Cart::add() should not be called statically http://localhost/Projects/E-commerce/cart/action
Controller
namespace App\ Http\ Controllers;
use Illuminate\ Http\ Request;
use Gloudemans\ Shoppingcart\ Cart;
class CartController extends Controller {
public
function cart() {
$cartcontent = Cart::Content();
return view('front_end/cart', ['cartcontent' => $cartcontent]);
}
public
function addcart(Request $request) {
$image = [$request - > product_image];
$add = Cart::add(
$request - > productid,
$request - > product_name,
$request - > qty,
$request - > product_price,
$image
);
if ($add) {
redirect('/cart');
}
}
html view
<tbody class="cart-table__body">
@foreach($cartcontent as $cartcontents)
<tr class="cart-table__row">
<td class="cart-table__column cart-table__column--image">
<a href="{{$cartcontents->product_image}}">
<img src="{{$cartcontents->product_image}}" alt="">
</a>
</td>
<td class="cart-table__column cart-table__column--product">
<a href="" class="cart-table__product-name">{{$cartcontents->product_name}}</a>
</td>
<td class="cart-table__column cart-table__column--price" data-title="Price">
{{$cartcontents->product_price}}</td>
<td class="cart-table__column cart-table__column--quantity" data-title="Quantity">
<div class="input-number">
<input class="form-control input-number__input" type="number" min="1" value="
{{$cartcontents->qty}}">
<div class="input-number__add"></div>
<div class="input-number__sub"></div>
</div>
</td>
<td class="cart-table__column cart-table__column--total" data-title="Total"></td>
<td class="cart-table__column cart-table__column--remove">
<a href="" class="btn btn-light btn-sm btn-svg-icon">
<svg width="12px" height="12px">
<use xlink:href="{{url('public/assets/images/sprite.svg#cross-12')}}"></use>
</svg>
</a>
</td>
</tr>
@endforeach
</tbody>