├── composer.json
├── phpunit.xml
├── readme.md
└── src
├── Laracasts
└── Flash
│ ├── Flash.php
│ ├── FlashNotifier.php
│ ├── FlashServiceProvider.php
│ ├── LaravelSessionStore.php
│ ├── Message.php
│ ├── OverlayMessage.php
│ ├── SessionStore.php
│ └── functions.php
└── views
├── message.blade.php
└── modal.blade.php
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laracasts/flash",
3 | "description": "Easy flash notifications",
4 | "license": "MIT",
5 | "authors": [
6 | {
7 | "name": "Jeffrey Way",
8 | "email": "jeffrey@laracasts.com"
9 | }
10 | ],
11 | "require": {
12 | "php": ">=5.4.0",
13 | "illuminate/support": "~5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0"
14 | },
15 | "require-dev": {
16 | "mockery/mockery": "dev-master",
17 | "phpunit/phpunit": "^6.1|^9.5.10|^10.5"
18 | },
19 | "autoload": {
20 | "psr-0": {
21 | "Laracasts\\Flash": "src/"
22 | },
23 | "files": [
24 | "src/Laracasts/Flash/functions.php"
25 | ]
26 | },
27 | "minimum-stability": "stable",
28 | "extra": {
29 | "laravel": {
30 | "providers": [
31 | "Laracasts\\Flash\\FlashServiceProvider"
32 | ],
33 | "aliases": {
34 | "Flash": "Laracasts\\Flash\\Flash"
35 | }
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 | ./tests/
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # Easy Flash Messages for Your Laravel App
2 |
3 | This composer package offers a Twitter Bootstrap optimized flash messaging setup for your Laravel applications.
4 |
5 | ## Installation
6 |
7 | Begin by pulling in the package through Composer.
8 |
9 | ```bash
10 | composer require laracasts/flash
11 | ```
12 |
13 | Next, as noted above, the default CSS classes for your flash message are optimized for Twitter Bootstrap. As such, either pull in the Bootstrap's CSS within your HTML or layout file, or write your own CSS based on these classes.
14 |
15 | ```html
16 |
17 | ```
18 |
19 | ## Usage
20 |
21 | Within your controllers, before you perform a redirect, make a call to the `flash()` function.
22 |
23 | ```php
24 | public function store()
25 | {
26 | flash('Welcome Aboard!');
27 |
28 | return home();
29 | }
30 | ```
31 |
32 | You may also do:
33 |
34 | - `flash('Message')->success()`: Set the flash theme to "success".
35 | - `flash('Message')->error()`: Set the flash theme to "danger".
36 | - `flash('Message')->warning()`: Set the flash theme to "warning".
37 | - `flash('Message')->overlay()`: Render the message as an overlay.
38 | - `flash()->overlay('Modal Message', 'Modal Title')`: Display a modal overlay with a title.
39 | - `flash('Message')->important()`: Add a close button to the flash message.
40 | - `flash('Message')->error()->important()`: Render a "danger" flash message that must be dismissed.
41 |
42 | With this message flashed to the session, you may now display it in your view(s). Because flash messages and overlays are so common, we provide a template out of the box to get you started. You're free to use - and even modify to your needs - this template how you see fit.
43 |
44 | ```html
45 | @include('flash::message')
46 | ```
47 |
48 | ## Example
49 |
50 | ```html
51 |
52 |
53 |
54 |
55 | Document
56 |
57 |
58 |
59 |
60 |
61 | @include('flash::message')
62 |
63 |
Welcome to my website...
64 |
65 |
66 |
67 |
68 |
69 |
70 |
73 |
74 |
75 |
76 | ```
77 |
78 | If you need to modify the flash message partials, you can run:
79 |
80 | ```bash
81 | php artisan vendor:publish --provider="Laracasts\Flash\FlashServiceProvider"
82 | ```
83 |
84 | The two package views will now be located in the `resources/views/vendor/flash/` directory.
85 |
86 | ```php
87 | flash('Welcome Aboard!');
88 |
89 | return home();
90 | ```
91 |
92 | ```php
93 | flash('Sorry! Please try again.')->error();
94 |
95 | return home();
96 | ```
97 |
98 | ```php
99 | flash()->overlay('You are now a Laracasts member!', 'Yay');
100 |
101 | return home();
102 | ```
103 |
104 | > [Learn exactly how to build this very package on Laracasts!](https://laracasts.com/lessons/flexible-flash-messages)
105 |
106 | ## Hiding Flash Messages
107 |
108 | A common desire is to display a flash message for a few seconds, and then hide it. To handle this, write a simple bit of JavaScript. For example, using jQuery, you might add the following snippet just before the closing `