darryldecode / laravelshoppingcart

Shopping Cart Implementation for Laravel Framework
1.33k stars 435 forks source link

[5.4] Call to undefined method Darryldecode\Cart\Facades\CartFacade::getContent() #90

Open farazappy opened 7 years ago

farazappy commented 7 years ago

Hello,

I am trying to use the instances feature of the package!

I did it like this ->

In AppServiceProvider.php I added the following in register() method ->

    $this->app->singleton('cart_deposit', function($app) {

        $storage = $app['session']; // laravel session storage
        $events = $app['events']; // laravel event handler
        $instanceName = 'cart_deposit'; // your cart instance name
        $session_key = 'AsASDMCks0ks1'; // your unique session key to hold cart items
        return new Cart(
            $storage,
            $events,
            $instanceName,
            $session_key
        );
    });

When I do any thing to this instance for example dd(app('cart_deposit')->getContent()); I get the error Call to undefined method Darryldecode\Cart\Facades\CartFacade::getContent()

50 #86 and #67 seem to encounter a similar or same issue!

@rashmi1403 solved her issue in #50 by using 'Cart' => 'Darryldecode\Cart\Cart', instead of 'Cart' => 'Darryldecode\Cart\Facades\CartFacade' in the aliases but that seems to give me a new issue Missing argument 5 for Darryldecode\Cart\Cart::__construct(),

Any help would be appreciated!

@darryldecode @pvdptje @ebisbe @frezno

darryldecode commented 7 years ago

Hi @farazappy , i don't see this problem. I made a quick demo with multiple instances (cart & wishlist) Im using laravel 5.4~ and shoppingcart 3.0~

here is the demo: http://phpstack-86254-257005.cloudwaysapps.com/cart here is the git repo of the demo: https://github.com/darryldecode/laravelshoppingcart-demo

thanks!

shirshak55 commented 6 years ago

It may due to to same session key like that please check your code.