Laravel 4 how to display flash message in view?

后端 未结 11 1188
粉色の甜心
粉色の甜心 2021-02-04 00:33

I\'m trying to get my flash message to display.

This is in my routing file

Route::post(\'users/groups/save\', function(){

return Redirect::to(\'users/g         


        
11条回答
  •  感动是毒
    2021-02-04 01:24

    {{ Session::get('success') }}
    

    This just echos the session variable 'success'. So when you use

    {{ Session::get('success') }} @if($success)

    {{ $success }}

    @endif

    you are seeing it's output along with the error of the next statement. Because with() function only sets the value in Session and will not set as a variable. Hence @if($success) will result in undefined variable error.

    As @Andreyco said,

    @if(Session::has('success'))
    

    {{ Session::get('success') }}

    @endif

    This should work.

    The reason you are not seeing it might be because the action you are performing is not success. And this does not require you to either reinstall xampp or modify php.ini.

提交回复
热议问题