Search
 
SCRIPT & CODE EXAMPLE
 

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

how to use sweetalert in laravel controller

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

sweetalert laravel

<script src="https://unpkg.com/sweetalert2@7.18.0/dist/sweetalert2.all.js"></script>
Comment

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) {
                              //
                    }         
            });
    });
});
Comment

sweet alert confirm box laravel

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

PREVIOUS NEXT
Code Example
Php :: php get variable name as a string 
Php :: get city name from latitude and longitude in php using geocode api 
Php :: single row data from table in laravel 
Php :: php array 
Php :: docker compose php 
Php :: create factory in laravel 8 
Php :: php $this 
Php :: php curl get body response 
Php :: controller class does not exist laravel 
Php :: remove array values php 
Php :: wordpress basic auth 
Php :: laravel with select 
Php :: define multiple variables in one line php 
Php :: php mysql 
Php :: Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255 
Php :: notification in laravel 8 
Php :: cron job setting for laravel in cpanel 
Php :: laravel route not found 
Php :: get email with preg grep php 
Php :: findOneBy 
Php :: magento 2 add cc transportbuilder 
Php :: add line in string column export php 
Php :: if cat 1 then send email woocommerce functions 
Php :: registerd navigations file uploadid 
Php :: codeigniter validate integer in php 
Php :: how to put cloth on 3d model using javascript and php 
Php :: data types of laravel migrations 
Php :: php ffi get load average 
Php :: Laravel Dropzone Attachment Required is not working as expected 
Php :: php version 7.4 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =