You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The most likely scenario is that you want to consume the flash message in a view. You can use the `message`, `class` and `level` properties on the view.
140
+
141
+
```blade
142
+
@if (flash()->message)
143
+
<div class="{{ flash()->class }}">
144
+
{{ flash()->message }}
145
+
</div>
146
+
147
+
@if(flash()->level === 'error')
148
+
This was an error.
149
+
@endif
150
+
@endif
151
+
```
152
+
139
153
Additionally, when you've added your own method, you can also pass that method name as a second parameter to `flash` itself:
140
154
141
155
```php
@@ -162,6 +176,20 @@ You can now use a `warning` method on `flash`:
162
176
flash()->warning('Look above you!');
163
177
```
164
178
179
+
You can pass the desired `level` as the third argument to `Message`.
180
+
181
+
```php
182
+
// in a service provider
183
+
use Spatie\Flash\Message;
184
+
185
+
\Spatie\Flash\Flash::macro('warning', function (string $message) {
// in the next request, after having flashed a message
190
+
flash()->level; // returns `my-level`
191
+
```
192
+
165
193
## Alternatives
166
194
167
195
This package is intended to be lightweight. If you need things like multiple messages, support for Bootstrap, overlays, ... take a look at [this excellent flash package](https://github.com/laracasts/flash) by [Jeffrey Way](https://github.com/JeffreyWay) or [Laraflash](https://github.com/coderello/laraflash) by [Ilya Sakovich](https://github.com/hivokas).
0 commit comments