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" 

1 Comment's

  1. 202507150031512529.jfif
    Bhawesh Bhaskar
    Reply

    Its really helpful

    Register to Reply

Add Comment

Register to Reply

About Author

Looking for a reliable and skilled web developer? I'm Bhawesh Bhaskar, a Senior Full Stack Software Developer with proven expertise in both front-end and back-end development. I provide professional website design, custom web application development, and robust PHP solutions using Laravel, CodeIgniter, and Core PHP. I help businesses create modern, responsive, and high-performance websites that drive results. Whether you're starting from scratch or need to upgrade your existing site, I deliver solutions tailored to your goals.
💼 Let’s build something great together — contact me today for a free consultation!