wvandeweyer/tall-flash

Flash notifications using the TALL stack

v1.0.6 2022-05-25 07:02 UTC

This package is auto-updated.

Last update: 2024-03-28 16:16:16 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

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.