Search code examples
laravellaravel-5laravel-4

Laravel Redirect Back with() Message


I am trying to redirect to the previous page with a message when there is a fatal error.

App::fatal(function($exception)
{
    return Redirect::back()->with('msg', 'The Message');
}

In the view trying to access the msg with

Sessions::get('msg')

But nothing is getting rendered, am I doing something wrong here?


Solution

  • Try

    return Redirect::back()->withErrors(['msg' => 'The Message']);
    

    and inside your view call this

    @if($errors->any())
    <h4>{{$errors->first()}}</h4>
    @endif