Laravel 5 laracasts flash 消息未显示错误div

Laravel 5 laracasts flash messaging not showing error div

我一直在尝试让用户知道他们的联系人表单中的消息已成功发送,我发现 This Github Repo 其中有一种 "easy" 闪烁方式Laravel 5 中的错误消息(我正在使用 Laravel 5.2)所以我继续尝试使用它,但我似乎无法让它工作。

类都找到了,这里的问题是我重定向后不闪

在我的master.blade.php

@if (Session::has('flash_notification.message'))
<div class="alert alert-{{ Session::get('flash_notification.level') }}">
    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

    {{ Session::get('flash_notification.message') }}
</div>
@endif

在我的routes.php

Route::post('sendemail', function () {

    $data = array(
        'name' => "Learning Laravel",
    );

    Mail::send('emails.welcome', $data, function ($message) {

        $message->from('email@provider', 'Learning Laravel!');

        $message->to('email@provider')->subject('Learning Laravel test email');

    });
        Flash::message('Thank you for contacting us, we will get back to you as soon as possible.');

        return Redirect::to('/');

});

我做错了什么/忘记了什么?

编辑完成routes.php

<?php

/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/

Route::get('/', function () {
    return view('index');
});

Route::post('sendemail', function () {

    $data = array(
        'name' => "Learning Laravel",
    );

    Mail::send('emails.welcome', $data, function ($message) {

        $message->from('email@provider', 'Learning Laravel!');

        $message->to('email@provider')->subject('Learning Laravel test email');

    });
        Session::put('flash_notification.message', 'Thank you for contacting us, we will get back to you as soon as possible.');

        return Redirect::to('/');

});
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/

Route::group(['middleware' => ['web']], function () {
    //
});

只需将 flash:message 更改为 Session::put 并确保它们在 "web" 中间件组下。

Route::group(['middleware' => ['web']], function () {

    Route::get('/', function () {
        return view('index');
    });

    Route::post('sendemail', function () {

        $data = array(
           'name' => "Learning Laravel",
        );

        Mail::send('emails.welcome', $data, function ($message) {

           $message->from('email@provider', 'Learning Laravel!');

           $message->to('email@provider')->subject('Learning Laravel test email');

       });
           Session::put('flash_notification.message', 'Thank you for contacting us, we will get back to you as soon as possible.');

           return Redirect::to('/');

    });


});