conquest/flash

This is my package flash

v0.1.1 2024-07-05 08:09 UTC

This package is auto-updated.

Last update: 2024-11-05 09:02:37 UTC


README

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

Flash exposes a global flash helper, which allows you to easily add flash messages to your session. These messages can be passed to your frontend using the HandleInertiaRequests middleware, see the usage section for more information.

Installation

You can install the package via composer:

composer require conquest/flash

Usage

The package ships with a global flash helper. Call this helper with a message to add flash messages to the session. You can configure the message, description and type. Two classes are provided which can be added separately. The Toast class allows for a duration to be set, a Banner class has no duration and will remain until dismissed.

If not specified, the flash message is assumed to be a Toast.

flash('Hello, World!')
flash()->toast('Hello, World!')
flash()->banner('Hello, world!')

To pass this to an Inertia frontend, add the following to the HandleInertiaRequests middleware array:

'flash' => Flash::messages(),

It is important to use the flash key if you intend on using the Vue + Inertia plugin.

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.