This is a package to send flash messages in a Laravel app via either the session storage or via Livewire.
Usage via session storage
class MyAwesomeController
{
public function store()
{
// ......
flash()->success('Hooray, we have saved your input');
// ....
}
}
To flash a message via Livewire, you must chain livewire($this)
. This will emit the information to the Flash notification component.
public function livewireMethod()
{
flash()->info('I want to share this info message.')->livewire($this);
}
Messages can be dismissible when chaining dismissable()
or not dismissable by chaining notDismissable()
or dismissable(false)
By default the messages will be dismissable. The default can be changed by publising the config file and changing the defaults.dismissable value.
The package uses AlpineJS to hide the message in this case.
You can display the messages by including this Livewire component in your template. It will display messages stored in the session, as well as messages emitted via Livewire.
<livewire:flash-message />
By default following levels are defined, but can be changed in the config file.
- info
- error
- warning
- success
When adding a level, you must also update the view flash-message.blade.php
. The styles are included in the blade file for the sole reason Tailwind will scan it when purging classes.
You can install the package via composer:
composer require wvandeweyer/tall-flash
You can publish the config file with:
php artisan vendor:publish --provider="Wvandeweyer\Flash\FlashServiceProvider"
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email wim@wimvandeweyer.be instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.