2017 © Pedro Peláez
 

library flash-toastr

Easy toastr.js flash notifications

image

hepplerdotnet/flash-toastr

Easy toastr.js flash notifications

  • Sunday, May 13, 2018
  • by HepplerDotNet
  • Repository
  • 1 Watchers
  • 1 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 115 % Grown

The README.md

Latest Stable Version License Total Downloads, (*1)

Flash Toastr

Flash Laravel Session Messages to Toastr.js, (*2)

Installation

First, pull in the package through Composer., (*3)

Run composer require HepplerDotNet/flash-toastr, (*4)

Only needed for Laravel < 5.6

And then include the service provider within config/app.php., (*5)

'providers' => [
    HepplerDotNet\FlashToastr\FlashServiceProvider::class,
];

And, for convenience, add a facade alias to this same file at the bottom:, (*6)

'aliases' => [
    'Flash' => HepplerDotNet\FlashToastr\Flash::class,
];

Usage

Within your controllers, before you perform a redirect..., (*7)

public function store()
{
    Flash::success('Welcome Aboard!','FlashToastr was successfully installed');

    return Redirect::home();
}

You may also do:, (*8)

  • Flash::info('Title','Message')
  • Flash::success('Title','Message')
  • Flash::error('Title','Message')
  • Flash::warning('Title','Message')
  • Flash::notify('Title', 'Message','Level')

This will set a few keys in the session:, (*9)

  • 'flash_notification.title' - The message title you're flashing
  • 'flash_notification.message' - The message you're flashing
  • 'flash_notification.level' - A string that represents the type of notification (good for applying CSS/Bootstrap class names)

Alternatively you may reference the flash() helper function, instead of the facade. Here's an example:, (*10)

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flash()->success('Logout successfull','You have been logged out.');

    return home();
}

You can even chain them to flash multiple messages at once., (*11)

/**
 * Destroy the user's session (logout).
 *
 * @return Response
 */
public function destroy()
{
    Auth::logout();

    flash()->success('Logout successfull','You have been logged out.')
    ->warning('Close Browser','You should close this Browser window now');

    return home();
}

With this messages flashed to the session, you may now display it in your view(s)., (*12)

@include('flash-toastr::message')

This will include the message.blade.php in to your view., (*13)

If you need to modify the flash message partials, you can run:, (*14)

php artisan vendor:publish --tag=flash-views

The message view will now be located in the resources/views/vendor/flash-toastr/ directory., (*15)

JavaScript Options for toastr.js

You can pass an array of options, which will be used to setup toastr.js, (*16)

{{ Config::set('flash-toastr.options', ['progressBar' => false,'positionClass' => 'toast-top-left']) }}

You can also publish the config file:, (*17)

php artisan vendor:publish --tag=flash-config

To publish both, config and views you can run:, (*18)

php artisan vendor:publish --tag=flash

See Toastr Documentation for all available options, (*19)

The Versions

13/05 2018

dev-master

9999999-dev

Easy toastr.js flash notifications

  Sources   Download

MIT

The Requires

 

by Patrick Heppler

12/05 2018

5.6.0

5.6.0.0

Easy toastr.js flash notifications

  Sources   Download

MIT

The Requires

 

by Patrick Heppler