OneMessage
For Easy Management of Messages in One singleton. Anywhere in the process you want to add a message just add it in the singleton and in the view just use it to display your messages., (*1)
Feature:
- Handles Flash or Same-Request Messages
- Handles Validation Messages
- Easy API
Setup:
in app/config/app.php
, (*2)
-
Add Service provider
add 'Howlowck\OneMessage\OneMessageServiceProvider'
in providers
array, (*3)
-
Add Facade
add 'OneMessage' => 'Howlowck\OneMessage\Facades\OneMessage'
in aliases
array, (*4)
Usage:
There are three type of messages: Error, Success, and Info., (*5)
Add Message, (*6)
OneMessage::addError(['authorization' => 'You are unauthorized!!!']);
or you can throw a MessageBag in there, (*7)
$v = Validator::make($data, $rules);
if ($v->fails()) {
OneMessage::addError($v->errors());
}
Add Message for Flash
When adding to the flash data, it will not be available in the current request., (*8)
OneMessage::addError(['authorization' => 'You are unauthorized!!!'], true);
get Message, (*9)
OneMessage::getError();
or get a specific message with key, (*10)
OneMessage::getError('authorization');