我有这样的基本代码:
Route::controller('admin', 'AdminController');
Route::when('admin/*', 'admin-auth');
Route::filter('admin-auth',function(){
if(!Auth::user())
return Redirect::to('login');
});
显然,当我运行我的应用程序时,Laravel 4路由无法运行身份验证检查。
在我看来,他们为Laravel 4修改了Laravel 3中的"模式"捕获。
尝试:
Route::when('admin*', 'admin-auth');
代替:
Route::when('admin/*', 'admin-auth');
试试这样调用你的路由。
Route::when('admin/*', ['before' => 'admin-auth', 'uses' => 'adminController@indexAction']);
这将工作时做Route::get/post不确定使用when ..仅供参考。
你必须在app/filters.php中编写Route::when()过滤器只需将Route::when('admin*', 'auth')移动到app/filters.php中,路径admin将需要login
只是假设普通的登录功能是你正在寻找的,所以只是使用了laravel认证过滤器。