我有中間件:如何將會話數據從中間件發送到佈局?
public function handle($request, Closure $next)
{
if (Auth::check() && Auth::user()->isStudent())
{
return $next($request);
}
return redirect('/');
}
我woould喜歡將數據發送到我的佈局與重定向,我tryed做這樣的:
$errors = ['You don't have permission, this side is ony for teachers']
return redirect('/login')->with('errors', $errors);
,但它不工作,我沒有按佈局」不要看這個。
這是我的佈局:
<html>
<head>
</head>
<body>
@if (session('errors'))
<div class="alert alert-dismissible alert-danger">
Wystąpiły następujące błędy:<br/>
<ul>
@foreach(session('errors') as $error)
<li>{!!$error!!}</li>
@endforeach
</ul>
</div>
@endif
@yield('content')
</body>
</html>
您的視圖看起來如何? –
我改變了我的帖子,並在'@ if之前添加了我的佈局 – wenus