* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com) */ class CartController extends Controller { /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ protected $_config; protected $cart; protected $cartProduct; protected $customer; public function __construct(CartRepository $cart, CartProductRepository $cartProduct, CustomerRepository $customer) { $this->middleware('customer')->except(['add', 'remove']); $this->customer = $customer; $this->cart = $cart; $this->cartProduct = $cartProduct; } /** * Function for guests * user to add the product * in the cart. * * @return Mixed */ public function add($id) { if(auth()->guard('customer')->check()) { Cart::add($id); } else { Cart::guestUnitAdd($id); } return redirect()->back(); } public function remove($id) { if(auth()->guard('customer')->check()) { Cart::remove($id); } else { Cart::guestUnitRemove($id); } return redirect()->back(); } }