tonning/flash

Flash for Laravel

Fund package maintenance!
tonning

0.1.5 2023-08-25 21:42 UTC

This package is auto-updated.

Last update: 2024-04-25 23:11:05 UTC


README

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

This composer package offers a Tailwind optimized flash messaging setup for your Laravel applications.

Installation

You can install the package via composer:

composer require tonning/flash

You can publish the view files with:

php artisan vendor:publish --provider="Tonning\Flash\FlashServiceProvider" --tag="flash-views"

You can publish the config file with:

php artisan vendor:publish --provider="Tonning\Flash\FlashServiceProvider" --tag="flash-config"

This is the contents of the published config file:

return [
    'display_errors' => true,
];

Usage

Anywhere in your application you can added a flash notification.

use Tonning\Flash\Flash;

Flash::info('A new software update is available. See what’s new in version 2.0.4.');

flash_info

Displaying notifications

@if(flash()->hasAny())
    {!! flash() !!}
@endif

Titles

You can also provide a title to your notifications that will be displayed along with it.

use Tonning\Flash\Flash;

Flash::warning('Please confirm your email address.', 'Attention needed');

flash_warning_single

Grouping

Notifications of the same type will be grouped in an unordered list.

use Tonning\Flash\Flash;

Flash::warning('Facilisis himenaeos nullam habitasse lacus sem auctor.');
Flash::warning('Please confirm your email address.', 'Attention needed');
Flash::warning('Facilisis egestas fermentum porttitor sapien eleifend amet.');

flash_warning_multiple_grouped

Errors

This package will by default also display any validation errors.

throw ValidationException::withMessages(['Something went wrong.']);

flash_error

This can be turned of in the config file.

'display_errors' => false,

Changelog

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

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

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