I am building a shopping cart using laravel and I want to update quantity in my session array.
i have used this link
How to update a single value in a Laravel Session Array?
but it did not work for me.
foreach($request->session()->get('shopping_cart') as $value){
if($value['code'] == $request->product_id){
echo $value['code'];
$value['quantity'] = $request->qty_val;
echo $value['quantity'].'<br />';
break;
}
}
dd($request->session()->get('shopping_cart'));
array:2 [▼
"" => array:5 [▼
"name" => "Fiona Nicholson"
"code" => null
"price" => "848"
"quantity" => "1"
"image" => "product_pics/1566371659.jpeg"
]
"sdfwef" => array:5 [▼
"name" => "Quentin Bryant"
"code" => "sdfwef"
"price" => "713"
"quantity" => "1"
"image" => "product_pics/1566371616.jpg"
]
]