i was trying to removing array item from Session. I show the array element following way:
<?php $i=1; ?>
@foreach(Session::get('product') as $row)
<tr>
<td>
<img src="" class="img-thumbnail" alt="" width="90px">
</td>
<td></td>
<td>
<a href="">
<button class="btn btn-danger btn-sm"><i class="fa fa-remove"></i></button></a>
</td>
</tr>
<?php $i++; ?>
@endforeach
And this is how i was trying to removing the key element :
public function deleteEnquote($id)
{
$remove = Product::where('id',$id)->first();
if(Session::has('product')){
foreach (Session::get('product') as $key => $value) {
if($value === $remove){
Session::pull('product.'.$key); // retrieving pen and removing
break;
}
}
}
return redirect('enquote');
}
But the problem is i couldn't delete the appropriate element from the Array.Means element not deleted.How do i delete the specific element from Session Array?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire