Package Data | |
---|---|
Maintainer Username: | spajz |
Maintainer Contact: | rasplinjac@gmail.com (Spajz) |
Package Create Date: | 2014-03-25 |
Package Last Update: | 2014-03-25 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-11 15:11:49 |
Package Statistics | |
---|---|
Total Downloads: | 8 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Application specific modules in Laravel 4 can be enabled by adding the following to your "composer.json" file:
"spajz/msg": "dev-master"
Then composer update.
Add a new provider to your providers list in "app/config/app.php":
'Spajz\Msg\MsgServiceProvider',
Also add a new alias to aliases list in "app/config/app.php":
'Msg' => 'Spajz\Msg\Facades\Msg',
If you want to edit default config file, just publish it to your app folder.
php artisan config:publish spajz/msg
// Default groups
Msg::success('Success message');
Msg::error('Error message');
Msg::danger('Danger message');
Msg::info('Info message');
Msg::warning('Warning message');
// Multiple messages
Msg::info(array('First message', 'Second'));
You can add custom groups to config, and then use them like default groups.
// Custom groups
Msg::exit('Exit message');
Msg::break('Break message');
// Custom key
Msg::custom('bar', $message, 'Bar group message format :message');
Msg::custom('foo', array($foo, $bar, 'Some text'), 'Format :message');
// Show all messages from the previous request
Msg::show();
// Only info messages
Msg::showInfo();
// With message format
Msg::showInfo($foo, ':key message: :message!');
// Show all messages in same request
Msg::instant();
// Only info with format
Msg::showInfoInstant($foo, ':key message: :message!');
// Custom group with format
Msg::showExitInstant($bar, ':key message: :message!');
// Add default template for all groups
Msg::setTemplate('myTemplate');
// Assign template to the specific group
Msg::setTemplates('info', 'myInfoTemplate');
// Assign Laravel Blade string like template
$blade = '<div class="box-{{ $key }}">';
$blade .= '@foreach ($messages as $message)';
$blade .= '<b>{{ $message }}</b>';
$blade .= '@endforeach';
$blade .= '</div>';
Msg::setTemplates('info', $blade, true);
// Delete all templates
Msg::deleteTemplates();
// Delete specific group template
Msg::deleteTemplates('danger');
// Add and show message instantly
echo Msg::danger('Something is wrong')->showDangerInstant();
// Set group format
Msg::setGroupFormat('info', '<b>:message</b>');
// Get raw messages data
Msg::getMessages();
// Set display mode single or group
Msg::setDisplayMode('single');