dev-master
9999999-devA library to send flash notifications to the user of your web app
MIT
The Requires
The Development Requires
by Andrew Reddin
A library to send flash notifications to the user of your web app
Display context specific messages to your users that will be displayed once then never shown again., (*1)
In addition to creating flash messages, this library allows you to write to the Laravel log file to allow you to keep track of what has been shown to the user, (*2)
composer require bytepath/flashbang
The library should be automatically installed via the Laravel package auto-discovery feature., (*3)
To add a flash message to the session use the FlashBang facade included in this package., (*4)
use Bytepath\FlashBang\Facades\FlashBang;
You can now send a message to the user of your application using one of the methods listed below, (*5)
/** * The requested action was successfully completed * @param $message The message to display to the user * @param $logMessage an optional message to add to the laravel log file */ FlashBang::success($message, $logMessage = null); /** * The requested action failed to complete * @param $message The message to display to the user * @param $logMessage an optional message to add to the laravel log file */ FlashBang::failure($message); /** * Display an informational message to the user * @param $message The message to display to the user * @param $logMessage an optional message to add to the laravel log file */ FlashBang::info($message); /** * Display a warning message to the user * @param $message The message to display to the user * @param $logMessage an optional message to add to the laravel log file */ FlashBang::warning($message);
To add a FlashBang message to your view, simply add the following snippet, (*6)
@include("flashbang::messages")
to whatever view you wish to display these messages on. Messages can be displayed multiple times on the same page if for whatever reason you wanted to do that., (*7)
By default this sub view will also show Form validation errors (and any other session errors). If you don't want this add $hideSessionErrors = true to the include directive, (*8)
@include("flashbang::messages", ["hideSessionErrors" => true])
A library to send flash notifications to the user of your web app
MIT