I am having trouble the last couple of days figuring this out, i tried googling and every answer I come across doesn't fix my problem
I am storing array of items in the cart but when retrieving the array, it's an object.
I want to be able to convert the object to an array.
Here is my code for storing the array in the cart session
$cart[$id] = [
"product_id" => $id,
"name" => $product->product_name,
"quantity" => $quantity,
"total" => $total,
];
$request->session()->put('cart', $cart);
but after I get the data from the cart it becomes an object
$cart = $request->session('cart');
I want to either convert this object back to array or retrieve the cart session data as array in the first place
$request->session('cart');is a valid thing to do? The docs mention either$request->session()->get('cart');orsession('cart')but not this syntax