Laravel 5:方法 - 私は次のようにダッシュボードの内側に戻ってページを制限するためのミドルウェアを作成している
namespace App\Http\Middleware;
use Closure;
class ValidateBackButton {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$response = $next($request);
$response->header('Cache-Control','nocache, no-store, max-age=0, must-revalidate')
->header('Pragma','no-cache')
->header('Expires','Sat, 01 Jan 1990 00:00:00 GMT');
return $response;
}
}
は私がアプリ/ HTTP /カーネルにミドルウェアを登録しています
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
'validateback' => 'App\Http\Middleware\ValidateBackButton',
];
.PHP私は私のコントローラでミドルウェアを使用しています:
public function __construct()
{
$this->middleware('auth');
$this->middleware('validateback');
}
すべてがそうですView.phpライン387に
BadMethodCallException:ビューに存在しない
法[ヘッダー]細かい、しかし、私は、次のエラーメッセージを取得します。
助けてください!
UPDATE
私はビューに問題があってはならないと思うので、私は以下のレイアウトファイルをしました。ビューのコードが長すぎてここに入れることはできません。
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8"/>
<title>SB Admin v2.0 in Laravel 5</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<meta content="" name="description"/>
<meta content="" name="author"/>
<link rel="stylesheet" href="{{ asset("assets/stylesheets/styles.css") }}" />
</head>
<body>
@yield('body')
<script src="{{ asset("assets/scripts/frontend.js") }}" type="text/javascript"></script>
</body>
</html>
おかげが、エラーがあるから来ることができたとして、それは、あなたのビューの –
郵便番号を助けていません。具体的には、コントローラがビューをレンダリングする方法。 –
私はレイアウトファイルを更新しました。ビューは、レイアウトの本体セクションの下にある通常のhtmlファイルです。 –