PHP code example of synergitech / laravel-sweetalert

1. Go to this page and download the library: Download synergitech/laravel-sweetalert library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

synergitech / laravel-sweetalert example snippets


use Alert;
html
@if (Session::has('sweetalert.alert'))
    <script>
        swal({
            text: "{!! Session::get('sweetalert.text') !!}",
            title: "{!! Session::get('sweetalert.title') !!}",
            timer: {!! Session::get('sweetalert.timer') !!},
            type: "{!! Session::get('sweetalert.type') !!}",
            showConfirmButton: "{!! Session::get('sweetalert.showConfirmButton') !!}",
            confirmButtonText: "{!! Session::get('sweetalert.confirmButtonText') !!}",
            confirmButtonColor: "#AEDEF4"
        });
    </script>
@endif
html
{% if session_has('sweetalert.alert') %}
    <script>
        swal({
            text: "{{ Session::get('sweetalert.text')|raw }}",
            title: "{{ Session::get('sweetalert.title')|raw }}",
            timer: {{ Session::get('sweetalert.timer')|raw }},
            type: "{{ Session::get('sweetalert.type')|raw }}",
            showConfirmButton: "{{ Session::get('sweetalert.showConfirmButton')|raw }}",
            confirmButtonText: "{{ Session::get('sweetalert.confirmButtonText')|raw }}",
            confirmButtonColor: "#AEDEF4"
        });
    </script>
{% endif %}