Last active
October 3, 2019 16:09
-
-
Save ffmit/e0442a07bc8a58dc127bd0ce9adbba10 to your computer and use it in GitHub Desktop.
Laravel Flash Messaging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please note: | |
Flash messages are made with Bulma (https://bulma.io) | |
Write in Controller | |
------------------- | |
request()->session()->flash('success', 'This is a success.'); | |
OR | |
request()->session()->flash('warning', 'This is a warning.'); | |
OR | |
request()->session()->flash('info', 'This is a information.'); | |
OR | |
request()->session()->flash('error', 'This is an error.'); | |
Write all these in View | |
----------------------- | |
@if ($message = Session::get('success')) | |
<div class="box" id="messagearea"> | |
<div class="notification is-success"> | |
<p>{{ Session::pull('success') }}</p> | |
</div> | |
</div> | |
@endif | |
@if ($message = Session::get('error')) | |
<div class="box" id="messagearea"> | |
<div class="notification is-danger"> | |
<p>{{ Session::pull('error') }}</p> | |
</div> | |
</div> | |
@endif | |
@if ($message = Session::get('warning')) | |
<div class="box" id="messagearea"> | |
<div class="notification is-warning"> | |
<p>{{ Session::pull('warning') }}</p> | |
</div> | |
</div> | |
@endif | |
@if ($message = Session::get('info')) | |
<div class="box" id="messagearea"> | |
<div class="notification is-info"> | |
<p>{{ Session::pull('info') }}</p> | |
</div> | |
</div> | |
@endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment