PHP code example of felixl7 / laravel-bootstrap-toast

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

    

felixl7 / laravel-bootstrap-toast example snippets


use FelixL7\Toast\Models\Toast;
...
Toast::default('Toast Title', 'Your Message');
Toast::success('Toast Title', 'Your Message');
Toast::info('Toast Title', 'Your Message');
Toast::warning('Toast Title', 'Your Message');
Toast::error('Toast Title', 'Your Message');

return redirect()->with('toasts', [Toast::success('Toast Title', 'Your Message')]);

Toast::custom('Toast Title', 'Your Message', 'your-type');

/**
    * Handle a failed validation attempt.
    *
    * @param  \Illuminate\Contracts\Validation\Validator  $validator
    * @return void
    *
    * @throws \Illuminate\Http\Exceptions\HttpResponseException
    */
protected function failedValidation(Validator $validator)
{
    throw new HttpResponseException(
        redirect()->back()
        ->withInput($this->except($this->dontFlash))
        ->withErrors($validator)
        ->with('bootstrap-toasts', [Toast::error('Validation Error', 'The validation of your input failed. Please checkout the validation messages.')])
    );
}
bash
php artisan vendor:publish --provider="FelixL7\Toast\ToastServiceProvider"
bash
php artisan vendor:publish --provider="FelixL7\Toast\ToastServiceProvider" --tag=config
bash
php artisan vendor:publish --provider="FelixL7\Toast\ToastServiceProvider" --tag=public