PHP code example of softon / sweetalert

1. Go to this page and download the library: Download softon/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/ */

    

softon / sweetalert example snippets

    
Softon\SweetAlert\SweetAlertServiceProvider::class,
   
'SWAL' => Softon\SweetAlert\Facades\SWAL::class,

@@

@@

use Softon\SweetAlert\Facades\SWAL;  

// Params: [Title,Text,Type,Options[]]
SWAL::message('Good Job','You have successfully logged In!','info');  
SWAL::message('Good Job','You have successfully logged In!','error');  
SWAL::message('Good Job','You have successfully logged In!','success',['timer'=>2000]);

// For All available options please refer the SweetAlert 2 Docs
 


// Message Type Can be `warning`, `error`, `success`, `info` and `question`. Based on this there are some convinence function that can be used instead of the message method.:
swal('Your Title','Text');
swal()->message('Good Job','You have successfully logged In!','info');  
swal()->message('Good Job','You have successfully logged In!','error');  
swal()->message('Good Job','You have successfully logged In!','success',['timer'=>2000]);
 

// Params [Title, Text, Options]
swal()->warning('Good Job','You have successfully logged In!',[]);
swal()->error('Good Job','You have successfully logged In!',[]);
swal()->success('Good Job','You have successfully logged In!',[]);
swal()->info('Good Job','You have successfully logged In!',[]);
swal()->question('Good Job','You have successfully logged In!',[]);
 
swal()->autoclose(2000)->message('Good Job','You have successfully logged In!','info'); 
swal()->autoclose(5000)->success('Good Job','You have successfully logged In!'); 
 
swal()->toast()->autoclose(2000)->message('Good Job','You have successfully logged In!','info'); 
 
swal()->button('Close Me')->message('Good Job','You have successfully logged In!','info'); 

// Button Params [Button Text,Button Colour, SWAL Style Enable / Disable, Style Class for Buttons]
swal()->button('Close Me','#efefef',false,'btn btn-primary')->info('Good Job','You have successfully logged In!'); 

// Possible Positions : `top`, `top-left`, `top-right`, `center`, `center-left`, `center-right`, `bottom`, `bottom-left`, or `bottom-right`
swal()->position('top')->message('Good Job','You have successfully logged In!','info'); 
 
swal()->position('bottom-right')->autoclose(3000)->toast()->message('This is A Custom Message');
bash
$ php artisan vendor:publish