Yasir
Yasir

Reputation: 101

Shopping Cart Error (LaravelShoppingcart)

I am using Crinsane/LaravelShoppingcart with Laravel 5. When I try to add items to Cart then it will display error

Non-static method Gloudemans\Shoppingcart\Cart::add() should not be called statically, assuming $this from incompatible context

Any help for resolve this..

Upvotes: 1

Views: 3891

Answers (2)

Mahfujur Rahman
Mahfujur Rahman

Reputation: 167

You will have to use the facade, you're trying to call the add method statically on the actual Cart class.

So don't do use Gloudemans\Shoppingcart\Cart; but use Cart; or use Gloudemans\Shoppingcart\Facades\Cart;.

Upvotes: 0

SimCity
SimCity

Reputation: 549

Add this line at the top of your PHP file:

use Cart;

instead of this:

use Gloudemans\Shoppingcart\Cart;

Upvotes: 5

Related Questions