PHP code example of synergitech / laravel-alert

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

    

synergitech / laravel-alert example snippets


use Alert;

...

Alert::message('Message', 'Optional Title');
Alert::info('Info Message', 'Optional Title');
Alert::success('Success Message', 'Optional Title');
Alert::error('Error Message', 'Optional Title');
Alert::warning('Warning Message', 'Optional Title');

alert()->message('Message', 'Optional Title');
alert()->info('Info Message', 'Optional Title');
alert()->success('Success Message', 'Optional Title');
alert()->error('Error Message', 'Optional Title');
alert()->warning('Warning Message', 'Optional Title');

@if (Session::has('alert.sweetalert'))
    <script>
        Swal.fire({!! Session::pull('alert.sweetalert') !!});
    </script>
@endif

alert()->warning('You need to complete extra fields', 'Unable to submit');

\Alert::warning('You need to complete extra fields')
    ->title('Unable to submit');

alert()->type('warning')
    ->message('You need to complete extra fields')
    ->title('Unable to submit');

// in your controller

alert()->output('toast')->info('Please check your settings.');

// OR

alert()->as('toast')->info('Please check your settings.');

// config/alert.php

'output' => [
    'sweetalert' => [
        'title' => 'title',
        'text' => 'text',
        'icon' => 'type',
    ],
    'toast' => [
        'text' => 'text',
        'icon' => 'type',
    ],
],
sh
php artisan vendor:publish --provider="SynergiTech\Alert\ServiceProvider"