Sweet alert in Laravel

Sweet alert can be easily cpnfigured in laravel using some javascript code.

Sweet alert can be easily cpnfigured in laravel using some javascript code.

Suppose, one have to show sweet alert after the success or fail response, it can be done in using below code.

 @if(session()->has('alert')) 
    
    $(function () {
        swal({
            title: "Sorry",
            text: "{{ session()->get('alert') }}",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "OK",
            cancelButtonText: "Contact Us",
            closeOnConfirm: false, 
            customClass: "Custom_Cancel"
        })
    });
 @endif 
 
sweet alert js src="https://unpkg.com/sweetalert2@7.8.2/dist/sweetalert2.all.js" 
 
jquery cdn src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js" 

0 Comment's

Add Comment

Register to Reply

About Author

I am Bhawesh Bhaskar, a Full Stack Sr. Software Developer. I am a good learner and always eager to learn new technologies. I can develop both client and server software. In addition to mastering HTML and CSS, I also know how to: Program a browser (like using JavaScript, jQuery) Program a server (like using Laravel, Code Ignitor or Core PHP).