我刚来Laravel ,
i have code in my controller's __construct like
if(Auth::check())
{
return View::make('view_page');
}
return Redirect::route('login')->withInput()->with('errmessage', 'Please Login to access restricted area.');
工作正常,但我想要的是.把这些代码放在每个控制器中真的很烦人,所以我想把这个验证身份和重定向到登录页面放在一个地方,可能是router.php
或filters.php
.
I have read some posts in forum as well as in stackoverflow
, and added code in filters.php
like below but that's too not working.
Route::filter('auth', function() {
if (Auth::guest())
return Redirect::guest('login');
});
Please help me to resolve this issue.