Php 分组路由不使用筛选器

Php 分组路由不使用筛选器,php,laravel,laravel-4,Php,Laravel,Laravel 4,我似乎无法使我的筛选器与分组的路由一起工作。无论我尝试什么,我总是能够在我不想进入的时候进入路线。我对拉威尔还是有点陌生,我不明白为什么它不起作用 这是路线 Route::group(数组('prefix'=>'bf4'),函数() { 路线::获取('记分板','HomeController@bf4scoreboard'); 路由::get('playerinfo/{id}','PlayerController@bf4info')->其中('id','[0-9]+'); 路径::get('p

我似乎无法使我的筛选器与分组的路由一起工作。无论我尝试什么,我总是能够在我不想进入的时候进入路线。我对拉威尔还是有点陌生,我不明白为什么它不起作用

这是路线

Route::group(数组('prefix'=>'bf4'),函数()
{
路线::获取('记分板','HomeController@bf4scoreboard');
路由::get('playerinfo/{id}','PlayerController@bf4info')->其中('id','[0-9]+');
路径::get('playersearch','PlayerController@searchbf4');
路线::post('playersearch','PlayerController@searchbf4');
//仅允许具有查看“战场4”管理部分权限的用户
路由::组(数组('prefix'=>'admin','before'=>'bf4_admin'),函数()
{
路由::获取('记录','BattlefieldAdminController@showAdKatRecords');
});
});
这是过滤器

Route::filter('bf4_admin',function()
{
如果(!trust::can('viewbf4admin'))
{
返回重定向::到('/');
}
});
问题是它总是允许我在不应该的时候查看该页面,因为我没有权限在用户角色上查看该页面

我做错了什么

编辑1

这是完整的路由文件。它很乱,但稍后会清理干净

App::缺少(函数($exception)
{
返回视图::make('error.404');
});
应用程序::错误(函数(ModelNotFoundException$e)
{
返回响应::视图('error.404');
});
路由::资源('upload','FileController');
路由::组(数组('prefix'=>'user'),函数()
{
路由::post('/create','UserController@store');
路由::获取('/login','UserController@login');
路由::post('/login','UserController@do_login');
路由::get('/confirm/{code}','UserController@confirm');
路由::post(“/忘记密码”,”UserController@do_forgot_password');
路由::get('/reset_password/{token}','UserController@reset_password');
路由::post('/reset_password','UserController@do_reset_password');
路由::获取('/logout','UserController@logout');
});
路由::组(数组('before'=>'auth'),函数()
{
路由::get('user/profile/{username?}','UserController@show_profile');
//路由::get('/profile/{name?}','UserController@show_profile');
路由::获取('/profile/edit','UserController@edit_profile');
});
//开始API路由
路由::组(数组('prefix'=>'api'),函数()
{
//一般战场路线
路由::组(数组('前缀'=>'战场'),函数()
{
路由::get('scoreboard/{id}/chat',函数($id)
{
$isBF4=(DB::table('tbl_server')->join('tbl_games','tbl_server.GameID','=','tbl_games.GameID')->其中('ServerID',$id)->pull('Name')='BF4')?TRUE:FALSE;
返回响应::json(Helper::getServerChatScoreboard($id,$isBF4));
});
路由::post('adminReports',数组('before'=>'auth'),函数()
{
返回响应::json(Helper::getAdminReports());
});
路由::post('playerSearch/{name?}',函数($name=FALSE)
{
返回响应::json(Helper::searchForPlayer($name));
});
路由::get('playerInfo/{id?}',函数($playerid=FALSE)
{
$info=Helper::buildPlayerProfile($playerid);
if(isset($info['status'])&&&$info['status']=='error')返回响应::json($info,404);
返回响应::json($info);
})->式中('id','[0-9]+');
});
//战场3特定路线
路由::组(数组('前缀'=>'战场/3'),函数()
{
路由::get('scoreboard/{id}',函数($id=NULL)
{
$b=新应用程序\模型\战场\ BF3SCOREBORD;
返回$b->初始化($id);
});
路由::post('scoreboard/{id}/admin',函数($id=NULL)
{
$b=新应用程序\模型\战场\ Bf3Admin;
返回$b->初始化($id);
});
路由::get('population',function()
{
$gameid=DB::table('tbl_games')->其中('Name','BF3')->pull('gameid');
返回响应::json(Helper::fetchServerPopulation($gameid));
});
});
路由::post('bf3/admin_reports',函数()
{
返回响应::json(数组('status'=>'success');
});
路由::组(数组('前缀'=>'战场/4'),函数()
{
路由::get('scoreboard/{id}',函数($id=NULL)
{
$b=新应用程序\模型\战场\ BF4记分板;
返回$b->初始化($id);
});
路由::post('scoreboard/{id}/admin',函数($id=NULL)
{
$b=新应用程序\模型\战场\ Bf4Admin;
返回$b->初始化($id);
});
路由::get('premessage',function())
{
return Helper::fetchPreMessages(输入::get('id'));
});
路由::get('population',function()
{
$gameid=DB::table('tbl_games')->其中('Name','BF4')->pull('gameid');
返回响应::json(Helper::fetchServerPopulation($gameid));
});
});
路由::组(数组('prefix'=>'common'),函数()
{
路由::post('adminReports',函数()
{
返回响应::json(Helper::getAdminReports());
});
路由::get('/repofeed',函数()
{
返回响应::json(Helper::fetchRepoActivity());
});
});
});
//结束API路由
//开始页面路由
路由::get('install','SetupController@install');
路由::获取('/',函数()
{
返回重定向::到('/dashboard');
});
路由::get('dashboard','HomeController@index');
路由::组(数组('prefix'=>'bf4'),函数()
{
路线::获取('记分板','HomeController@bf4scoreboard');
路由::get('playerinfo/{id}','PlayerController@bf4info')->其中('id','[0-9]+');
路径::get('playersearch','PlayerController@searchbf4');
路线::post('playersearch','PlayerController@searchbf4');
App::missing(function($exception)
{
    return View::make('error.404');
});

App::error(function(ModelNotFoundException $e)
{
    return Response::view('error.404');
});

Route::filter('bf4_admin', function()
{
        return 'denied';
});

Route::resource('upload', 'FileController');

Route::group(array('prefix' => 'user'), function()
{
    Route::post('/create', 'UserController@store');
    Route::get('/login', 'UserController@login');
    Route::post('/login', 'UserController@do_login');
    Route::get('/confirm/{code}', 'UserController@confirm');
    Route::post('/forgot_password', 'UserController@do_forgot_password');
    Route::get('/reset_password/{token}', 'UserController@reset_password');
    Route::post('/reset_password', 'UserController@do_reset_password');
    Route::get('/logout', 'UserController@logout');
});

Route::group(array('before' => 'auth'), function()
{
    Route::get('user/profile/{username?}', 'UserController@show_profile');
    //Route::get('/profile/{name?}', 'UserController@show_profile');
    Route::get('/profile/edit', 'UserController@edit_profile');
});

// Begin API Route
Route::group(array('prefix' => 'api'), function()
{
    // General Battlefield Routes
    Route::group(array('prefix' => 'battlefield'), function()
    {
        Route::get('scoreboard/{id}/chat', function($id)
        {
            $isBF4 = (DB::table('tbl_server')->join('tbl_games', 'tbl_server.GameID', '=', 'tbl_games.GameID')->where('ServerID', $id)->pluck('Name') == 'BF4') ? TRUE : FALSE;
            return Response::json(Helper::getServerChatScoreboard($id, $isBF4));
        });

        Route::post('adminReports', array('before' => 'auth'), function()
        {
            return Response::json(Helper::getAdminReports());
        });

        Route::post('playerSearch/{name?}', function($name = FALSE)
        {
            return Response::json(Helper::searchForPlayer($name));
        });

        Route::get('playerInfo/{id?}', function($playerid = FALSE)
        {
            $info = Helper::buildPlayerProfile($playerid);

            if(isset($info['status']) && $info['status'] == 'error') return Response::json($info, 404);

            return Response::json($info);

        })->where('id', '[0-9]+');
    });


    // Battlefield 3 Specific Routes
    Route::group(array('prefix' => 'battlefield/3'), function()
    {
        Route::get('scoreboard/{id}', function($id = NULL)
        {
            $b = new App\Models\Battlefield\Bf3Scoreboard;
            return $b->initialize($id);
        });

        Route::post('scoreboard/{id}/admin', function($id = NULL)
        {
            $b = new App\Models\Battlefield\Bf3Admin;
            return $b->initialize($id);
        });

        Route::get('population', function()
        {
            $gameid = DB::table('tbl_games')->where('Name', 'BF3')->pluck('GameID');
            return Response::json(Helper::fetchServerPopulation($gameid));
        });
    });

    Route::post('bf3/admin_reports', function()
    {
        return Response::json(array('status' => 'success'));
    });

    Route::group(array('prefix' => 'battlefield/4'), function()
    {
        Route::get('scoreboard/{id}', function($id = NULL)
        {
            $b = new App\Models\Battlefield\Bf4Scoreboard;
            return $b->initialize($id);
        });

        Route::post('scoreboard/{id}/admin', function($id = NULL)
        {
            $b = new App\Models\Battlefield\Bf4Admin;
            return $b->initialize($id);
        });

        Route::get('premessage', function()
        {
            return Helper::fetchPreMessages(Input::get('id'));
        });

        Route::get('population', function()
        {
            $gameid = DB::table('tbl_games')->where('Name', 'BF4')->pluck('GameID');
            return Response::json(Helper::fetchServerPopulation($gameid));
        });
    });

    Route::group(array('prefix' => 'common'), function()
    {
        Route::post('adminReports', function()
        {
            return Response::json(Helper::getAdminReports());
        });

        Route::get('/repofeed', function()
        {
            return Response::json(Helper::fetchRepoActivity());
        });
    });
});
// End API Route

// Begin Page Route
Route::get('install', 'SetupController@install');

Route::get('/', function()
{
    return 'home';
});

Route::get('dashboard', 'HomeController@index');

Route::group(array('prefix' => 'bf4'), function()
{
    Route::get('scoreboard', 'HomeController@bf4scoreboard');
    Route::get('playerinfo/{id}', 'PlayerController@bf4info')->where('id', '[0-9]+');
    Route::get('playersearch', 'PlayerController@searchbf4');
    Route::post('playersearch', 'PlayerController@searchbf4');

    // Only users with the permission to view the battlefield 4 admin section are allowed
    Route::group(array('prefix' => 'admin', 'before' => 'bf4_admin'), function()
    {
        Route::get('records', 'BattlefieldAdminController@showAdKatRecords');
    });
});

Route::group(array('prefix' => 'bf3'), function()
{
    Route::get('scoreboard', 'HomeController@bf3scoreboard');
    Route::get('playerinfo/{id}', 'PlayerController@bf3info')->where('id', '[0-9]+');
    Route::get('playersearch', 'PlayerController@searchbf3');
    Route::post('playersearch', 'PlayerController@searchbf3');
    Route::group(array('prefix' => 'admin', 'before' => 'bf3_admin'), function()
    {
        Route::get('records', 'BattlefieldAdminController@showAdKatRecords');
    });
});

Route::when('admin/*', 'site_admin');

Route::group(array('prefix' => 'admin', 'before' => 'auth'), function()
{
    Route::get('memberlist', 'AdminController@memberList');
    Route::get('user/{id}', 'AdminController@showuser')->where('id', '[0-9]+');
    Route::get('user/{id}/edit', 'AdminController@edituser')->where('id', '[0-9]+');
    Route::post('user/{id}/edit', 'AdminController@do_edituser')->where('id', '[0-9]+');
});


// +--------+----------------------------------------------+----------------------------------------------+---------------------------------------------+------------------+---------------+
// | Domain | URI                                          | Name                                         | Action                                      | Before Filters   | After Filters |
// +--------+----------------------------------------------+----------------------------------------------+---------------------------------------------+------------------+---------------+
// |        | GET upload                                   | upload.index                                 | FileController@index                        |                  |               |
// |        | GET upload/create                            | upload.create                                | FileController@create                       |                  |               |
// |        | POST upload                                  | upload.store                                 | FileController@store                        |                  |               |
// |        | GET upload/{upload}                          | upload.show                                  | FileController@show                         |                  |               |
// |        | GET upload/{upload}/edit                     | upload.edit                                  | FileController@edit                         |                  |               |
// |        | PUT upload/{upload}                          | upload.update                                | FileController@update                       |                  |               |
// |        | PATCH upload/{upload}                        |                                              | FileController@update                       |                  |               |
// |        | DELETE upload/{upload}                       | upload.destroy                               | FileController@destroy                      |                  |               |
// |        | POST user/create                             |                                              | UserController@store                        |                  |               |
// |        | GET user/login                               |                                              | UserController@login                        |                  |               |
// |        | POST user/login                              |                                              | UserController@do_login                     |                  |               |
// |        | GET user/confirm/{code}                      |                                              | UserController@confirm                      |                  |               |
// |        | POST user/forgot_password                    |                                              | UserController@do_forgot_password           |                  |               |
// |        | GET user/reset_password/{token}              |                                              | UserController@reset_password               |                  |               |
// |        | POST user/reset_password                     |                                              | UserController@do_reset_password            |                  |               |
// |        | GET user/logout                              |                                              | UserController@logout                       |                  |               |
// |        | GET user/profile/{username?}                 |                                              | UserController@show_profile                 | auth             |               |
// |        | GET profile/edit                             |                                              | UserController@edit_profile                 | auth             |               |
// |        | GET api/battlefield/scoreboard/{id}/chat     |                                              | Closure                                     |                  |               |
// |        | POST api/battlefield/adminReports            |                                              | Closure                                     | auth             |               |
// |        | POST api/battlefield/playerSearch/{name?}    |                                              | Closure                                     |                  |               |
// |        | GET api/battlefield/playerInfo/{id?}         |                                              | Closure                                     |                  |               |
// |        | GET api/battlefield/3/scoreboard/{id}        |                                              | Closure                                     |                  |               |
// |        | POST api/battlefield/3/scoreboard/{id}/admin |                                              | Closure                                     |                  |               |
// |        | GET api/battlefield/3/population             |                                              | Closure                                     |                  |               |
// |        | POST api/bf3/admin_reports                   |                                              | Closure                                     |                  |               |
// |        | GET api/battlefield/4/scoreboard/{id}        |                                              | Closure                                     |                  |               |
// |        | POST api/battlefield/4/scoreboard/{id}/admin |                                              | Closure                                     |                  |               |
// |        | GET api/battlefield/4/premessage             |                                              | Closure                                     |                  |               |
// |        | GET api/battlefield/4/population             |                                              | Closure                                     |                  |               |
// |        | POST api/common/adminReports                 |                                              | Closure                                     |                  |               |
// |        | GET api/common/repofeed                      |                                              | Closure                                     |                  |               |
// |        | GET install                                  |                                              | SetupController@install                     |                  |               |
// |        | GET /                                        |                                              | Closure                                     |                  |               |
// |        | GET dashboard                                |                                              | HomeController@index                        |                  |               |
// |        | GET bf4/scoreboard                           |                                              | HomeController@bf4scoreboard                |                  |               |
// |        | GET bf4/playerinfo/{id}                      |                                              | PlayerController@bf4info                    |                  |               |
// |        | GET bf4/playersearch                         |                                              | PlayerController@searchbf4                  |                  |               |
// |        | POST bf4/playersearch                        |                                              | PlayerController@searchbf4                  |                  |               |
// |        | GET bf4/admin/records                        |                                              | BattlefieldAdminController@showAdKatRecords | bf4_admin        |               |
// |        | GET bf3/scoreboard                           |                                              | HomeController@bf3scoreboard                |                  |               |
// |        | GET bf3/playerinfo/{id}                      |                                              | PlayerController@bf3info                    |                  |               |
// |        | GET bf3/playersearch                         |                                              | PlayerController@searchbf3                  |                  |               |
// |        | POST bf3/playersearch                        |                                              | PlayerController@searchbf3                  |                  |               |
// |        | GET bf3/admin/records                        |                                              | BattlefieldAdminController@showAdKatRecords | bf3_admin        |               |
// |        | GET admin/memberlist                         |                                              | AdminController@memberList                  | auth, site_admin |               |
// |        | GET admin/user/{id}                          |                                              | AdminController@showuser                    | auth, site_admin |               |
// |        | GET admin/user/{id}/edit                     |                                              | AdminController@edituser                    | auth, site_admin |               |
// |        | POST admin/user/{id}/edit                    |                                              | AdminController@do_edituser                 | auth, site_admin |               |
// +--------+----------------------------------------------+----------------------------------------------+---------------------------------------------+------------------+---------------+