0

I am using laraadmin in one of my application but module generated by admin not confirming when deleting any record. Please some one help me How to add delete confirmation in laraadmin modules?

Sandeep Yadav
  • 591
  • 1
  • 4
  • 14

1 Answers1

1

I do not know how to work with laraadmin but You can do that by java script:

Blade:

@foreach (items as item)
    <form class="delete" action="{{ route('item.destroy', $item->id) }}" method="POST">
        <input type="hidden" name="_method" value="DELETE">
        <input type="hidden" name="_token" value="{{ csrf_token() }}" />
        <input type="submit" value="Delete">
    </form>
@endforeach

JS:

<script>
    $(".delete").on("submit", function(){
        return confirm("Do you want to delete this item?");
    });
</script>

And if you need preety nice confirmation design You can use Sweet Alert JS Library: https://sweetalert.js.org/guides/

Adam Kozlowski
  • 5,606
  • 2
  • 32
  • 51