Hello Devs,

In this tutorial, we are going to learn about laravel 7/6 sweetalert record delete. Given below is the short example of sweet alert2 for laravel 7/6.

Follow this step by step guide given below:

Step 1: 

Add Table and Dummy Records

INSERT INTO `products` (`id`, `name`, `email`, `created_at`, `updated_at`) VALUES
(1, 'Mln, 'Pqr@gmail.com', NULL, NULL),
(3, 'Demo, 'Demo@gmail.com', NULL, NULL),

Step 2: 

Add New Route routes/web.php

Route::get('users', 'TestController@index');

Step 3: 

Create UserController


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;

class TestController extends Controller
    public function index()
      $users = User::get();
      return view('user',compact('users'));

    public function destroy(Request $request,$id)
      return back();

Step 4:

 Create user blade file

<!DOCTYPE html>
  <title>Laravel Sweet Alert2 Confirm Delete Example-rathorji.in</title>
  <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.css">
  <script src="http://demo.itsolutionstuff.com/plugin/jquery.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.2.0/sweetalert2.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.2.0/sweetalert2.all.min.js"></script>
  <meta name="csrf-token" content="{{ csrf_token() }}">
<body class="bg-dark">
  <div class="container">
    <div class="row">
      <div class="col-md-8 offset-md-2">
        <div class="card mt-5">
          <div class="card-header">
            <h5>Laravel Sweet Alert2 Confirm Delete Example-rathorji.in</h5>
          <div class="card-body">
            <table class="table table-bordered">
                <td width="5%">Action</td>
                @foreach($users as $user)
                  <td>{{ $user->name }}</td>  
                  <td>{{ $user->email }}</td>  
                    <button class="btn btn-danger btn-flat btn-sm remove-user" data-id="{{ $user->id }}" data-action="{{ route('users.destroy',$user->id) }}" onclick="deleteConfirmation({{$user->id}})"> Delete</button>
<script type="text/javascript">
    function deleteConfirmation(id) {
            title: "Delete?",
            text: "Please ensure and then confirm!",
            type: "warning",
            showCancelButton: !0,
            confirmButtonText: "Yes, delete it!",
            cancelButtonText: "No, cancel!",
            reverseButtons: !0
        }).then(function (e) {

            if (e.value === true) {
                var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');

                    type: 'POST',
                    url: "{{url('/users')}}/" + id,
                    data: {_token: CSRF_TOKEN},
                    dataType: 'JSON',
                    success: function (results) {

                        if (results.success === true) {
                            swal("Done!", results.message, "success");
                        } else {
                            swal("Error!", results.message, "error");

            } else {

        }, function (dismiss) {
            return false;

Run this command:

php artisan serve

Open this URL:


I hope this example helps you.