Processing math: 100%

Sunday, 2 June 2019

A simple Laravel Flash message helper

I needed a simple way to ensure a one off flash message would show to a user on some of my larval apps, so I used the following idea

// put this as a partial in you app.blade.php
@if(session('global.flash'))
<section style="position: fixed; right: 1rem; top: 3.2rem; z-index: 999">
<div class="tile is-ancestor" >
<div class="tile is-parent is-vertical">
@foreach(session('global.flash') as key => notice)
<div class="tile is-child">
<div class="notification is-{{$key}} animated fadeInDown" onclick="this.remove()">
<span class="delete"></span>
{{ $notice }}
</div>
</div>
@endforeach
</div>
</div>
</section>
@endif
view raw flash.blade.php hosted with ❤ by GitHub
<?php
/**
* web.php
*/
Route::get('/', function () {
session()->flash('setting.flash.success', 'Hello and Welcome to the App :)');
return view('welcome');
});
view raw web.php hosted with ❤ by GitHub


I recall seeing this implemented in a few places, so nothing new, it is just using some self explanatory styling and the bulma.io library for css.

I did make a tailwindcss version which I will update and add later :)

0_o

No comments:

Post a Comment

Buy Me A Coffee
Thank you for visiting. You can now buy me a coffee!