PHP Laravel session flash alert message not showing

You appear to be using the session class, rather than the session helper laravel injects on the service container.

If you're using Laravel 5.8, session in blade is a helper function as per the docs here:

https://laravel.com/docs/5.8/responses#redirecting-with-flashed-session-data

An example

Route::post('user/profile', function () {
    // Update the user's profile...

    return redirect('dashboard')->with('status', 'Profile updated!');
});

So use the helper function in blade like this:

@if (session('status'))
    <div class="alert alert-success">
        {{ session('status') }}
    </div>
@endif

NB: This will only work if you are using a page submit. If it's a javascript submit you may need to refresh the page to get the alert to show up.

Tags:

Php

Laravel