“Comment utiliser SweetAlert dans Laravel Controller” Réponses codées

Comment utiliser SweetAlert dans Laravel Controller

@if (Session::has('sweet_alert.alert'))
<script>
  swal({!! Session::get('sweet_alert.alert') !!});
</script>
@endif
Friendly Flamingo

SweetAlertbox à Laravel

-> 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/
WinMaw

SweetAlert Laravel

<script src="https://unpkg.com/[email protected]/dist/sweetalert2.all.js"></script>
Determined Dormouse

Sweet Alert Confirm Box Laravel

$(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) {
                              //
                    }         
            });
    });
});
Crazy Capybara

Sweet Alert Confirm Box Laravel

<a href="" class="button" data-id="{{$user->id}}">Delete</a>
Crazy Capybara

Réponses similaires à “Comment utiliser SweetAlert dans Laravel Controller”

Questions similaires à “Comment utiliser SweetAlert dans Laravel Controller”

Plus de réponses similaires à “Comment utiliser SweetAlert dans Laravel Controller” dans PHP

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code