wvandeweyer / tall-flash
Flash notifications using the TALL stack
Fund package maintenance!
wvandeweyer
Requires
- php: ^8.0
- illuminate/contracts: ^8.0|^9.0
- livewire/livewire: ^2.5
Requires (Dev)
- brianium/paratest: ^6.2
- nunomaduro/collision: ^5.3
- orchestra/testbench: ^6.15
- phpunit/phpunit: ^9.4
- vimeo/psalm: ^4.4
README
This is a package to send flash messages in a Laravel app via either the session storage or via Livewire.
Usage
Usage via session storage
class MyAwesomeController { public function store() { // ...... flash()->success('Hooray, we have saved your input'); // .... } }
Livewire Flash Message
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); }
Dismissable Messages
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.
Display Messages
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 />
Message types
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.
Installation
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"
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
If you discover any security related issues, please email wim@wimvandeweyer.be instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.