[Vuejs]-Where should I instantiate my cart with PHPCart in Laravel 5?

0👍

If you want access from multiple methods on your controller the simplest way is to use dependency injection in the constructor of your controller.

protected $cart;

public function __construct(Cart $cart)
{
    $this->cart = $cart;
}

Then in your various controller methods you can simply access it like

$this->cart->add()

Leave a comment