Level 29
Read the cart, remove the item and push it back.
1 like
I'm using sessions to store the list of Formation items that the user has in his cart.
Here's how an item is added to the cart:
session()->push('cart', $request->formation_id);
I want to add the ability to remove items from the cart. I see this in the documentation :
session()->forget('key');
... but I don't see how to use this when the value is an array. How can I remove an item from the session cart? The controller method receives the formation_id as a parameter, like the add() method does.
Read the cart, remove the item and push it back.
Please or to participate in this conversation.