Q:

Flash message background color not disappearing after Refreshing the page redirected to

When I edit a post I get the flash message as expected in my laravel project but after refreshing the page I redirect to only the text disappears and the background color remains. What could be the problem?
My code in my controller in my update() function is:
return redirect(route('post.index'))->with('flash', 'Post Edited Successfully');
My code in my .blade.php file is:
<h4 class="alert alert-info" >{{ session('flash') }}</h4>

A:

It seems your h4 tag always remains either there is a flash message or not. When there is a message its displaying the message but when there's none h4 tag is showing with empty value and the background is coming from that. you need to check if there a flash message.
@if (session('flash'))
    <h4 class="alert alert-info" >{{ session('flash') }}</h4>
@endif

