larapac / flash
Easy flash notifications
Installs: 1 973
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
- illuminate/session: ~5.0|^6.0|^7.0
- illuminate/support: ~5.0|^6.0|^7.0
Requires (Dev)
- mockery/mockery: 0.9.*
- phpunit/phpunit: ^6.1
This package is not auto-updated.
Last update: 2024-10-31 14:27:40 UTC
README
Simple Flash Messages for Your Laravel App
Features:
- Messages by levels (info, success, warning, danger);
- Multiple messages (of different types and for types);
- Stack of messages and ability to pick messages of a single type;
- Additional message data (by array or current interface);
- Message sent on a page does not replace a message sent by redirecting to the page;
- Does not need linking with JS or message front-end.
Installation
composer require larapac/flash
Usage
To send a message use helper flash()
flash('Some info message');
In template:
@foreach (flash()->messages() as $message) {{ $message->level }}: {{ $message->text }} @endforeach
Messages have properties
text
level
(success, info, warning, danger)
Messages have levels and service allows to send multiple messages:
flash('Info level message'); flash()->info('Info level message two'); flash()->success('Success level message'); flash()->warning('Warning level message'); flash()->warning('Warning level message two'); flash()->danger('Danger level message'); flash()->error('Danger level message from alias method');
And we can get messages of only one single level:
Errors: @foreach(flash()->messages('danger') as $message) {{ $message->text }}; @endforeach @foreach($errors->all() as $message) {{ $message }}; @endforeach
Add extra data message:
//use array flash()->info('Message', ['important' => true, 'timeout' => 3]); //fluent style flash()->info('Message')->important()->timeout(3);
@foreach (flash()->messages() as $message) {{ $message->level }}: {{ $message->text }} {{ $message->important ? '!' : '.' }} @endforeach
Other
If you want it to be more simple, use class from gist: FlashMessageSender
Or see these packages: