In this tutorial we are going to learn about Remove Product From wishlist.
So let see how can remove product from wishlist.
Go to the Wishlist Controller and here lets create a function here


public function removeProductFromWishlist(Request $request)
{
$rowId = $request->rowId;
Cart::instance("wishlist")->remove($rowId);
return redirect()->route('wishlist.list');
}




Now lets create the route for this


Route::delete('/wishlist/remove',[WishlistController::class,'removeProductFromWishlist'])->name('wishlist.remove');


Now go the wishlist.blade.php file and create a form here


<form id="deleteFromWishlist" action="{{route('wishlist.remove')}}" method="POST">
@csrf
@method('delete')
<input type="hidden" id="rowId" name="rowId" />
</form>



Now create a JavaScript function here


@push('scripts')
<script>
function removeFromWishlist(rowId)
{
$("#rowId").val(rowId);
$("#deleteFromWishlist").submit();
}

</script>
@endpush


Now call this function from remove icon


<a href="javascript:void(0)" class="icon" onclick="removeFromWishlist('{{$item->rowId}}')">
<i class="fas fa-times"></i>
</a>



Now its done so lets check this so refresh the page
Now lets remove this product from here
Just click this icon and you can see product has been removed


Now lets make working this clear all items link
For that go to the wishlist controller and lets create a new function here


public function clearWishlist()
{
Cart::instance("wishlist")->destroy();
return redirect()->route('wishlist.list');
}


Now create a route for this function


Route::delete('/wishlist/clear',[WishlistController::class,'clearWishlist'])->name('wishlist.clear');


Now go the wishlist.blade.php and add form here


<form id="clearWishlist" action="{{route('wishlist.clear')}}" method="POST">
@csrf
@method('delete')
</form>


Now add JavaScript function here


@push('scripts')
<script>
function clearWishlist()
{
$("#clearWishlist").submit();
}
</script>
@endpush


Now call this JavaScript function from here on click event


<div class="row">
<div class="col-md-12 text-end">
<a href="javascript:void(0)" onclick="clearWishlist()">Clear All Items</a>
</div>
</div>


Now its done so lets check it
Refresh the page
Now clear all item from wishlist
So click here
And you can see here all items are rmoved from here
So in this way you can Remove Product from wishlist