Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Laravel handle-all-flash-messages partial-view
@if ($errors->any())
<div class="alert alert-danger">
@foreach ($errors->all() as $error)
{!! $error !!}<br/>
@endforeach
</div>
@endif
@if (Session::get('flash_success'))
<div class="alert alert-success">
@if(is_array(Session::get('flash_success')))
<ul>
@foreach(Session::get('flash_success') as $msg)
<li>{!! $msg !!}</li>
@endforeach
</ul>
@else
{!! Session::get('flash_success') !!}
@endif
</div>
@endif
@if (Session::get('flash_warning'))
<div class="alert alert-warning">
@if(is_array(Session::get('flash_warning')))
<ul>
@foreach(Session::get('flash_warning') as $msg)
<li>{!! $msg !!}</li>
@endforeach
</ul>
@else
{!! Session::get('flash_warning') !!}
@endif
</div>
@endif
@if (Session::get('flash_info'))
<div class="alert alert-info">
@if(is_array(Session::get('flash_info')))
<ul>
@foreach(Session::get('flash_info') as $msg)
<li>{!! $msg !!}</li>
@endforeach
</ul>
@else
{!! Session::get('flash_info') !!}
@endif
</div>
@endif
@if (Session::get('flash_danger'))
<div class="alert alert-danger">
@if(is_array(Session::get('flash_danger')))
<ul>
@foreach(Session::get('flash_danger') as $msg)
<li>{!! $msg !!}</li>
@endforeach
</ul>
@else
{!! Session::get('flash_danger') !!}
@endif
</div>
@endif
@if (Session::get('flash_message'))
<div class="alert alert-info">
@if(is_array(Session::get('flash_message')))
<ul>
@foreach(Session::get('flash_message') as $msg)
<li>{!! $msg !!}</li>
@endforeach
</ul>
@else
{!! Session::get('flash_message') !!}
@endif
</div>
@endif
@shryder

This comment has been minimized.

Copy link

@shryder shryder commented Oct 31, 2019

Thats so bad

@binarweb

This comment has been minimized.

Copy link

@binarweb binarweb commented Jun 25, 2021

@shryder pointing out obvious stuff doesn't help. how about showing us how you would have done it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment