Skip to content

Instantly share code, notes, and snippets.

@YavorK
Last active August 7, 2024 21:30
Show Gist options
  • Save YavorK/7aa6e839dbe93e8854e4b033e31836a4 to your computer and use it in GitHub Desktop.
Save YavorK/7aa6e839dbe93e8854e4b033e31836a4 to your computer and use it in GitHub Desktop.
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
Copy link

shryder commented Oct 31, 2019

Thats so bad

@binarweb
Copy link

@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