Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

sweetalertbox in 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/
 
PREVIOUS NEXT
Tagged: #sweetalertbox #laravel
ADD COMMENT
Topic
Name
4+7 =