mercredi 3 octobre 2018

Lost on shopping Cart Library

This might be a foolish or at least a beginners question, but if i'm here writing this it's because I'm pretty lost after some hours.

I'm working in a Laravel 5.7 project with darryldecode/laravelshoppingcart library (since Crinsane's is not compatible with 5.7, dah). I just don't understand how this libraries work, how do you share the cart's information at the controller with the whole site, with session? the library does for you? or you need to do it?. At need the cart at the checkout page and at the header (so the whole site).

My (incomplete) Controller:

 public function store(Request $request)
{
    $loggedUser = auth()->user()->id;
    $id = $request->id;
    $title = $request->title;
    $price = $request->price;
    $cart = \Cart::session($loggedUser)->add($id, $title, $price, 1, []);
    return view('cart');
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire