I am developing a shopping cart in laravel in which I want to remove array in the session but it is not working.
I have tried these:
https://www.allphptricks.com/simple-shopping-cart-using-php-and-mysql/
https://laracasts.com/discuss/channels/laravel/remove-array-element-from-session?page=1
but it did not work
foreach($request->session()->get('shopping_cart') as $key => $value){
if($value['code'] == $request->remove_id){
$request->session()->forget("shopping_cart.". $request->remove_id);
break;
}
}
array:4 [▼
"fh5hhr34" => array:5 [▼
"name" => "Wilma Goodman"
"code" => "fh5hhr34"
"price" => "412"
"quantity" => "2"
"image" => "product_pics/1566372402.jpeg"
]
"ghtzzr" => array:5 [▼
"name" => "Lillian Hays"
"code" => "ghtzzr"
"price" => "187"
"quantity" => "4"
"image" => "product_pics/1566372214.jpg"
]
]