PHP code example of sudam-shrestha / sudam-sweet-alert

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

    

sudam-shrestha / sudam-sweet-alert example snippets


return [
    // Modal alert defaults
    'position' => 'center',
    'timer' => null,
    'show_confirm_button' => true,

    // Toast defaults
    'toast_position' => 'top-end',
    'toast_timer' => 3000,

    // Design — applies to both modals and toasts
    'show_close_button' => true,
    'confirm_button_color' => '#3085d6',
    'cancel_button_color' => '#d33',
    'background' => null,
    'text_color' => null,
    'buttons_styling' => true,
    'custom_class' => [],

    'cdn' => 'https://cdn.jsdelivr.net/npm/sweetalert2@11',
];

use Sudam\SudamSweetAlert\Facades\SudamSweetAlert;

SudamSweetAlert::success('Saved!', 'Your changes have been saved.');
SudamSweetAlert::error('Failed', 'Something went wrong.');
SudamSweetAlert::warning('Careful', 'This action cannot be undone.');
SudamSweetAlert::info('Heads up', 'Here is something you should know.');
SudamSweetAlert::question('Are you sure?', 'This will delete the record.');

return redirect()->back();

SudamSweetAlert::toast('success', 'Saved successfully!');

SudamSweetAlert::error('Failed', 'Could not save record.', [
    'position' => 'bottom-start',
    'timer' => 5000,
    'showCloseButton' => false,
]);

SudamSweetAlert::success('Saved!')
    ->timer(4000)
    ->position('top-end')
    ->showCloseButton(false);
bash
php artisan vendor:publish --tag="sudam-sweet-alert-config"
bash
php artisan vendor:publish --tag="sudam-sweet-alert-views"