-> npm install sweetalert2
->resources/app.js
window.Swal = require("sweetalert2");
->resources/sass/app.scss
@import "~sweetalert2";
->you must carry with "with method" in Controller
return redirect()->route('index')->with('status',"You $contact->name Updated")
->resources/view/layouts/app.blade.php
@if(session('status'))
<script>
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true,
didOpen: (toast) => {
toast.addEventListener('mouseenter', Swal.stopTimer)
toast.addEventListener('mouseleave', Swal.resumeTimer)
}
})
Toast.fire({
icon: 'success',
title: '{{session('status')}}'
})
</script>
@endif
-> https://sweetalert2.github.io/
@if (Session::has('sweet_alert.alert'))
<script>
swal({!! Session::get('sweet_alert.alert') !!});
</script>
@endif
<script src="https://unpkg.com/sweetalert2@7.18.0/dist/sweetalert2.all.js"></script>
$(document).on('click', '.button', function (e) {
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Are you sure!",
type: "error",
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes!",
showCancelButton: true,
},
function() {
$.ajax({
type: "POST",
url: "{{url('/destroy')}}",
data: {id:id},
success: function (data) {
//
}
});
});
});
<a href="" class="button" data-id="{{$user->id}}">Delete</a>