保護路由

2018-02-24 15:52 更新

路由中間件 只允許通過認證的用戶訪問指定的路由。Laravel 默認提供了 auth 中間件,放在 app\Http\Middleware\Authenticate.php。 你需要做的只是將其加到一個路由定義中:

// With A Route Closure...

Route::get('profile', ['middleware' => 'auth', function()
{
    // Only authenticated users may enter...
}]);

// With A Controller...

Route::get('profile', ['middleware' => 'auth', 'uses' => 'ProfileController@show']);
以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號