I was trying add list of products into session. For that i used array. But i don't want to store same product again into the session. I used the following controller to avoid duplicate entry in session. But it doesn't work. Means it doesn't let me add to the session array at all. How can i solve the problem? Thanks!
public function postEnquote(Request $request)
{
$product = Product::where('id',$request->Input(['product_id']))->first();
if(Session::has('product')){
foreach (Session::get('product') as $key => $value) {
if($value->id === $remove->id){
return redirect('shop-list');
}
else{
session()->push('product', $product);
}
}
}
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire