Laravelshoppingcart: Non-static method Gloudemans\Shoppingcart\Cart::add() should not be called statically

Created on 17 Jul 2016  路  7Comments  路  Source: Crinsane/LaravelShoppingcart

Just started with your package.
From readme
Cart::add('293ad', 'Product 1', 1, 9.99);

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Gloudemans\Shoppingcart\Cart;
use App\Product;

use App\Http\Requests;

class CartController extends Controller
{
    public function add($id)
    {
        $product = Product::find($id);
        $item = Cart::add($product->id, $product->title, 1, 9.99);
        dd($item);
    }
}

where i am wrong ? Thanks.

Most helpful comment

You're using the cart class instead of the facade. Change the use statement to the facade

All 7 comments

You're using the cart class instead of the facade. Change the use statement to the facade

oops, ok thanks :)
also if i am there, is that good idea to use your plugin with Angular on front side?

use Gloudemans\Shoppingcart\Facades\Cart;

Ofcourse you can use it with Angular

ok, thanks tomorrow i will continue.

Maybe you can help me, which way is correct. Create some .factory('Cart') and after for example i press Add to cart product - send to backend and save this information in Angular Cookies? And in "routeChangeEvent" checking cookies + backend or how? Do i need use cookies on frontend side? :)
Thanks.

I'm not that familiar with Angular, so I can help you, sorry!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yansentan picture yansentan  路  6Comments

ChrisThompsonTLDR picture ChrisThompsonTLDR  路  5Comments

lagask picture lagask  路  8Comments

shahin7511 picture shahin7511  路  8Comments

nasirkhan picture nasirkhan  路  8Comments