Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gnahotelsolutions/flasher
🔦 Flash notification messages into Laravel's Session
https://github.com/gnahotelsolutions/flasher
flashed-messages flasher hacktoberfest laravel laravel-package notifications php
Last synced: 1 day ago
JSON representation
🔦 Flash notification messages into Laravel's Session
- Host: GitHub
- URL: https://github.com/gnahotelsolutions/flasher
- Owner: gnahotelsolutions
- License: mit
- Created: 2019-06-06T16:11:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-19T07:12:12.000Z (over 1 year ago)
- Last Synced: 2024-10-20T09:18:47.468Z (about 1 month ago)
- Topics: flashed-messages, flasher, hacktoberfest, laravel, laravel-package, notifications, php
- Language: PHP
- Homepage:
- Size: 46.9 KB
- Stars: 3
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Flasher
[![Latest Version on Packagist](https://img.shields.io/packagist/v/gnahotelsolutions/flasher.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/flasher)
[![Total Downloads](https://img.shields.io/packagist/dt/gnahotelsolutions/flasher.svg?style=flat-square)](https://packagist.org/packages/gnahotelsolutions/flasher)
![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)The `gnahotelsolutions/flasher` package provides an easy way to interact with flashed messages in your Laravel application.
## Install
You can install the package via composer:
```bash
$ composer require gnahotelsolutions/flasher
```## Usage
The messages are stored in the `notifications` session key.
All notifications have a default `duration` property set to 5 seconds. You can use this property in your JavaScript to make notifications disappear automatically.
### Creating notifications
```php
Flasher::info("Welcome, {$user->name}");Flasher::error('Incorrect password');
Flasher::warning('Remember to change your password');
Flasher::success('Password changed!');
```If you want to use custom types, you can use the method `createNotification`
```php
Flasher::createNotification('store', 'Someone bought a product!', null);
```### Check if there are pending notifications
```php
@if (Flasher::any())
...
@endif
```### Iterating over notifications
```php
@foreach(Flasher::all() as $notification)
{{ $notification->getMessage() }}
@endforeach
```If you're using [Bootstrap](https://getbootstrap.com) in your project, you can use `getBootstrapClass()` method.
It will replace `error` with `danger` to match the framework's CSS class.## Testing
``` bash
phpunit
```## Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## License
The MIT License (MIT).