In this video, we will learn about adding confirmation on record deletion.

Let's see how we can add confirmation on record deletion. For that, switch to the project and open the admin-category-component.blade.php view file.

Now, inside this file, go inside the table and modify the delete link by writing the following code:


<td>
<a href="#" onclick="confirm('Are you sure, You want to delete this category?') || event.stopImmediatePropagation()" wire:click.prevent="deleteCategory({{$category->id}})" style="margin-left:10px; "><i class="fa fa-times fa-2x text-danger"></i></a>
</td>

Now, let's check it. Switch to the project and refresh the page.

Now, let's delete any category. Just click on the delete link. After clicking on the delete link, you will see the confirmation message: "Are you sure you want to delete this category?"

If you click on "Cancel", the record is safe. Click one more time on the delete link. This time, click on "OK". You will see that the category has been deleted.

Now, let's add deletion confirmation with the products. So, for that, open the admin-product-component.blade.php file and add the following code inside the table:


<td>
<a href="#" onclick="confirm('Are you sure, you want to delete this product?') || event.stopImmediatePropagation()" style="margin-left:10px;" wire:click.prevent="deleteProduct({{$product->id}})"><i class="fa fa-times fa-2x text-danger"></i></a>
</td>

Now, let's check it. Go to the "All Products" page and delete any product. After clicking on the delete link, you will get the delete confirmation message.

So, in this way, you can add confirmation on record deletion. That's all about adding confirmation on record deletion.