@Sinnbeck Hi, thanks for a time.
Here is my code when I put to a session
public function addToCart(Request $request)
{
$product = Product::findOrFail($request->get('product'));
$cake = [
'title' => $request->get('title'),
'note' => $request->get('note'),
'shape' => $request->get('shape'),
'price' => $request->get('price'),
];
$request->session()->put("cart.cake." . $product->slug, $cake);
return redirect()->route('cart');
}
I have 2 cakes, the first has a url-slug mickey-mouse and the second a mini-mouse. When I try to add the first cake to the cart, the session looks like this:
[
"cart" => [
"cake" => [
"mickey-mouse" => [
'title' => 'some data',
'note' => 'some data',
'shape' => 'some data',
'price' => 'some data',
]
]
]
]
But when I try to add another cake to the cart, the session looks like this:
[
"cart" => [
"cake" => [
"mini-mouse" => [
'title' => 'some data',
'note' => 'some data',
'shape' => 'some data',
'price' => 'some data',
]
]
]
]
But it should look like this:
[
"cart" => [
"cake" => [
"mickey-mouse" => [
'title' => 'some data',
'note' => 'some data',
'shape' => 'some data',
'price' => 'some data',
],
"mini-mouse" => [
'title' => 'some data',
'note' => 'some data',
'shape' => 'some data',
'price' => 'some data',
]
]
]
]
And on the cart page, when I try to list everything from the session, I only have only mini-mouse cake in the session.