PHP code example of rzl-app / laravel-toaster

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

    

rzl-app / laravel-toaster example snippets


return [
  /*
  |--------------------------------------------------------------------------
  | Session Flash Name for Toaster
  |--------------------------------------------------------------------------
  |
  | This defines the session key name used to flash the toaster data.
  | It will be retrieved on the frontend after a redirect or page reload.
  |
  | Note: The Value must be string and not empty or only space or as blank
  |       value, if invalid value will return fallback as "toast".
  |
  | Default: 'toast'
  |
  | Example:
  | session()->flash('toast', [...]);
  |
  */
  'session_name'  => "toast",

  /*
  |--------------------------------------------------------------------------
  | Settings Toaster Options As Session Flash or Only Return As Props Array.
  |--------------------------------------------------------------------------
  |
  | Toaster Mode: Flash Session or Return as Props Array
  | Return Format:
  |
  |  * false: `Session` -> `session()->flash("toast", [
  |               $title, $message, $type, $durationClose
  |           ]);`
  |
  |  * true: Props json output or array.
  |
  */
  'as_prop'       => false,
];

toaster('Profile saved!');

toaster('Unauthorized action!', 'error', 5000);
toaster('Heads up!', 'warning', 0); // No auto close

toasterSuccess('Data saved!');
toasterError('Something wrong...');
toasterInfo('Heads up!');
toasterWarning('Careful!');

return [
    'toast' => toasterAsProps('Welcome back!', 'info')
];

return response()->json([
    'toast' => toasterErrorAsProps('Invalid data!')
]);
bash
php artisan vendor:publish --tag="RzlLaravelToaster"