2017 © Pedro Peláez
 

library toastr

toastr.js flush notifications for Laravel 5

image

yoeunes/toastr

toastr.js flush notifications for Laravel 5

  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 78 % Grown

The README.md

Toastr.js notifications for Laravel

:eyes: This package helps you to add toastr.js notifications to your Laravel projects., (*1)

Latest Stable Version Latest Unstable Version Total Downloads License , (*2)

toastr, (*3)

Install

You can install the package using composer, (*4)

composer require yoeunes/toastr

Usage:

The usage of this package is very simple and straightforward. it only required one step to use it :, (*5)

Use toastr() helper function inside your controller to set a toast notification for info, success, warning or error, (*6)

// Display an error toast with no title
toastr()->error('Oops! Something went wrong!');

As an example:, (*7)

<?php

namespace App\Http\Controllers;

use App\Post;
use App\Http\Requests\PostRequest;
use Illuminate\Database\Eloquent\Model;

class PostController extends Controller
{
    public function store(PostRequest $request)
    {
        $post = Post::create($request->only(['title', 'body']));

        if ($post instanceof Model) {
            toastr()->success('Data has been saved successfully!');

            return redirect()->route('posts.index');
        }

        toastr()->error('An error has occurred please try again later.');

        return back();
    }
}

Other Options

// Set a warning toast, with no title
toastr()->warning('Are you sure you want to proceed ?');

// Set a success toast, with a title
toastr()->success('Data has been saved successfully!', 'Congrats');

// Set an error toast, with a title
toastr()->error('Oops! Something went wrong!', 'Oops!');

// Override global config options from 'config/toastr.php'
toastr()->success('Data has been saved successfully!', 'Congrats', ['timeOut' => 5000]);

Other api methods:

You can also chain multiple messages together using method chaining, (*8)

toastr()
    ->info('Welcome back')
    ->success('Data has been saved successfully!')
    ->warning('Are you sure you want to proceed ?');

You can use toastr('') instead of toastr()->success(), (*9)

function toastr(string $message = null, string $type = 'success', string $title = '', array $options = []);

So, (*10)

  • toastr($message) is equivalent to toastr()->success($message)
  • toastr($message, 'info') is equivalent to toastr()->info($message)
  • toastr($message, 'warning') is equivalent to toastr()->warning($message)
  • toastr($message, 'error') is equivalent to toastr()->error($message)

configuration:

As optional if you want to modify the default configuration, you can publish the configuration file:, (*11)

php artisan vendor:publish --provider="Yoeunes\Toastr\ToastrServiceProvider"
// config/toastr.php
<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Toastr options
    |--------------------------------------------------------------------------
    |
    | Here you can specify the options that will be passed to the toastr.js
    | library. For a full list of options, visit the documentation.
    |
    */

    'options' => [
        'closeButton'       => true,
        'closeClass'        => 'toast-close-button',
        'closeDuration'     => 300,
        'closeEasing'       => 'swing',
        'closeHtml'         => '<button><i class="icon-off"></i></button>',
        'closeMethod'       => 'fadeOut',
        'closeOnHover'      => true,
        'containerId'       => 'toast-container',
        'debug'             => false,
        'escapeHtml'        => false,
        'extendedTimeOut'   => 10000,
        'hideDuration'      => 1000,
        'hideEasing'        => 'linear',
        'hideMethod'        => 'fadeOut',
        'iconClass'         => 'toast-info',
        'iconClasses'       => [
            'error'   => 'toast-error',
            'info'    => 'toast-info',
            'success' => 'toast-success',
            'warning' => 'toast-warning',
        ],
        'messageClass'      => 'toast-message',
        'newestOnTop'       => false,
        'onHidden'          => null,
        'onShown'           => null,
        'positionClass'     => 'toast-top-right',
        'preventDuplicates' => true,
        'progressBar'       => true,
        'progressClass'     => 'toast-progress',
        'rtl'               => false,
        'showDuration'      => 300,
        'showEasing'        => 'swing',
        'showMethod'        => 'fadeIn',
        'tapToDismiss'      => true,
        'target'            => 'body',
        'timeOut'           => 5000,
        'titleClass'        => 'toast-title',
        'toastClass'        => 'toast',
    ],
];

For a list of available options, see toastr.js' documentation., (*12)

Credits

License

MIT, (*13)

The Versions

22/05 2018

dev-master

9999999-dev https://github.com/yoeunes/toastr

toastr.js flush notifications for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php lumen messages laravel 5 notification toastr alerts flush laravel toastr laravel 5.6 laravel notification toastr js flush notifications laravel flush notifications flush messages yoeunes

22/05 2018

v1.0.2

1.0.2.0 https://github.com/yoeunes/toastr

toastr.js flush notifications for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php lumen messages laravel 5 notification toastr alerts flush laravel toastr laravel 5.6 laravel notification toastr js flush notifications laravel flush notifications flush messages yoeunes

20/05 2018

v1.0.1

1.0.1.0 https://github.com/yoeunes/toastr

toastr.js flush notifications for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php lumen messages laravel 5 notification toastr alerts flush laravel toastr laravel 5.6 laravel notification toastr js flush notifications laravel flush notifications flush messages yoeunes

08/02 2018
08/01 2018

v1.1

1.1.0.0 https://github.com/yoeunes/toastr

Easy toastr notifications for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel php laravel 5 notification toastr