No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

alert.blade.php 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. @if (Session::has('alert.config') || Session::has('alert.delete'))
  2. @if (config('sweetalert.animation.enable'))
  3. <link rel="stylesheet" href="{{ config('sweetalert.animatecss') }}">
  4. @endif
  5. @if (config('sweetalert.theme') != 'default')
  6. <link href="https://cdn.jsdelivr.net/npm/@sweetalert2/theme-{{ config('sweetalert.theme') }}" rel="stylesheet">
  7. @endif
  8. @if (config('sweetalert.alwaysLoadJS') === false && config('sweetalert.neverLoadJS') === false)
  9. <script src="{{ $cdn ?? asset('vendor/sweetalert/sweetalert.all.js') }}"></script>
  10. @endif
  11. <script>
  12. @if (Session::has('alert.delete'))
  13. document.addEventListener('click', function(event) {
  14. if (event.target.matches('[data-confirm-delete]')) {
  15. event.preventDefault();
  16. Swal.fire({!! Session::pull('alert.delete') !!}).then(function(result) {
  17. if (result.isConfirmed) {
  18. var form = document.createElement('form');
  19. form.action = event.target.href;
  20. form.method = 'POST';
  21. form.innerHTML = `
  22. @csrf
  23. @method('DELETE')
  24. `;
  25. document.body.appendChild(form);
  26. form.submit();
  27. }
  28. });
  29. }
  30. });
  31. @endif
  32. @if (Session::has('alert.config'))
  33. Swal.fire({!! Session::pull('alert.config') !!});
  34. @endif
  35. </script>
  36. @endif