doupi3874 2014-11-10 03:19
浏览 99
已采纳

Laravel 5 Auth Filter不起作用

I just tried Laravel 5 after a time at 4.2.. The docs says it is possible to use 'before' => 'auth' as always, but for me it does not work.

I have no idea whats wrong, I have read the docs, search on internet but seems not to find anything. My code looks as:

$router->group(['before' => 'auth'], function($router)
{

     // 
     $router->get('admin', function()
     {
          return View::make('admin.index');
     });

     //
     $router->get('login', function()
     {
          return View::make('admin.login');
     });

});

Anyone can see what I doing wrong here?

  • 写回答

1条回答 默认 最新

  • dsgdsf12312 2014-11-10 07:32
    关注

    In laravel5 filters are removed. Instead you can use middleware classes which are more clean.

    In this blog you can read more about the middleware classes and that they're a replacement of filters.

    If you want to do it with self written routes you can use this:

    Route::group(['middleware' => 'auth'], function()
    {
    
         Route::get('admin', function()
         {
              return View::make('admin.index');
         });
    
         Route::->get('login', function()
         {
              return View::make('admin.login');
         });
    
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?