Php Flash消息在laravel 5.2中不起作用

Php Flash消息在laravel 5.2中不起作用,php,laravel-5.2,Php,Laravel 5.2,我正在尝试让flash消息在Laravel 5.2中工作。一切似乎都是正确的,但当我进入/提醒时,什么也没有发生。有什么建议吗 下面是我的routes.php Route::group(['middleware' => ['web']], function(){ Route::get('/', [ 'uses' => 'HomeController@index', 'as' => 'welcome', ]); Route::get('/al

我正在尝试让flash消息在Laravel 5.2中工作。一切似乎都是正确的,但当我进入/提醒时,什么也没有发生。有什么建议吗

下面是我的routes.php

  Route::group(['middleware' => ['web']], function(){
  Route::get('/', [
    'uses' => 'HomeController@index',
    'as' => 'welcome',
    ]);

  Route::get('/alert', function()
  {
    return redirect()->route('welcome')->with('info', 'You have signed up!');
  });
});
以下是我的alerts.blade.php

 @if (Session::has('info'))
<div class="alert">
     {{ Session::get('info') }}
</div>
@endif
@if(会话::has('info'))
{{Session::get('info')}
@恩迪夫
下面是我的master.blade.php

<!DOCTYPE html>
<html>
<head>
   <title>@yield('title')</title>
   <link rel="stylesheet"              href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

</head>

<body>
   @include('includes.header')
   <div class="container">
     @yield('content')
     @include('includes.alerts')
    </div>
 </body>
</html>

@收益率(‘所有权’)
@include('includes.header')
@产量(‘含量’)
@include('includes.alerts')

您应该尝试按照文档建议使用,而不是使用facade\Session

发件人:

当然,在用户被重定向到新页面后,您可以从会话中检索并显示闪现的消息。例如,使用刀片式语法:


我更改了我的代码,与您的代码一样,但页面上仍然没有显示任何内容。我更新了我的代码,请注意,我有
session('status')
没有
session('info')
是的,我理解您的意思。我将代码保留在会话('info')中,但由于无效,当我尝试您的上一个建议时,出现了一个错误。。。routes.php第23行中的FatalErrorException:调用未定义的方法illumb\Support\Facades\Request::flash()解决了问题。我不得不从中间件中删除我的路由。要了解新的更新路线,不需要在里面。
@if (session('info'))
<div class="alert">
    {{ session('info') }}
</div>
@endif
Route::get('/alert', function(\Illuminate\Http\Request $request)
{
    $request->session()->flash('info', 'You have signed up!');
    return redirect()->route('welcome');
});