我試圖顯示閃存數據,但顯示不正確。它顯示:Laravel 5中的閃存數據
{{ Session::get('flash_message') }}
,但它應該是信息
"Your article has been created"
這有什麼錯我的代碼?謝謝!
在我的控制,我有:
public function store(ArticleRequest $request)
{
Auth::user()->articles()->create($request->all());
\Session::flash('flash_message', 'Your article has been created');
return redirect('articles');
}
我app.blade.php
是:
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>App Name - @yield('title')</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ elixir('css/all.css') }}">
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="js/app.js"></script>
</head>
<body>
<div class="container">
@if(Session::has('flash_message'))
<div class="alert alert-success">{{ Session::get('flash_message') }}</div>
@endif
@yield('content')
</div>
@yield('footer')
</body>
</html>
在我route.php我有以下幾點:大括號顯示內容爲字符串不變量。
<?php
Blade::setContentTags('<%', '%>'); // for variables and all things Blade
Blade::setEscapedContentTags('<%%', '%%>'); // for escaped data
Route::get('/', function() {
\t return 'Home Page';
});
Route::get('blade', function() {
return view('about');
});
Route::get('about', '[email protected]');
Route::get('foo', ['middleware' => 'manager', function() {
\t return 'this page may only be viewed by managers';
}]);
Route:resource('articles', 'ArticlesController');
Route::controllers([
\t 'auth' => 'Auth\AuthController',
\t 'password' => 'Auth\PasswordController'
]);
是的,我寫了這個 - 看到我的代碼,但問題是,它顯示爲:'{{會話:: get('flash_message')}}'不是消息'「您的文章已經創建」 –
你的代碼看起來很好,但你說的很奇怪!你可以顯示你的'routes.php'嗎?當重定向到「文章」時,你究竟做了什麼? – akmozo
我創建了一篇新文章,然後重定向到所有文章。我的thisnk問題是{{花括號。它不顯示消息,但它顯示爲字符串。我會更新我的問題並添加路線。 –