我有一个中间件来检查路由的子集操作
public function handle($request, Closure $next)
{
$requests = $request->route()->getAction();
$userPermissions = Session::get('userPermissions');
$module = $requests['module'];
$permission= $requests['permission'];
}
我的路线是
Route::resource('/users', 'BackEnd\'UsersController', ['module' => 'acl', 'permission'=>'createUser']);
这是我转储请求时得到的结果
array (size=7)
'middleware' =>
array (size=2)
0 => string 'authentication' (length=14)
1 => string 'authorization' (length=13)
'as' => string 'user.index' (length=10)
'uses' => string 'App\Http\Controllers\BackEnd'UsersController@index' (length=50)
'controller' => string 'App\Http\Controllers\BackEnd'UsersController@index' (length=50)
'namespace' => string 'App\Http\Controllers' (length=20)
'prefix' => string '/' (length=1)
'where' =>
array (size=0)
empty
我缺少的是'模块'和#39;许可'在该数组中如果我使用不同的路线说
Route::get('/users/all', ['uses'=> 'BackEnd\UsersController@index',
'module'=>'acl',
'permission'=>'createUser'
]);
这是请求的转储结果,这是我想要的资源路由。
array (size=8)
'middleware' =>
array (size=2)
0 => string 'authentication' (length=14)
1 => string 'authorization' (length=13)
'uses' => string 'App\Http\Controllers\BackEnd\UsersController@index' (length=50)
'module' => string 'acl' (length=3)
'permission' => string 'createUser' (length=10)
'controller' => string 'App\Http\Controllers\BackEnd\UsersController@index' (length=50)
'namespace' => string 'App\Http\Controllers' (length=20)
'prefix' => null
'where' =>
array (size=0)
empty
答案 0 :(得分:0)
资源在选项方面存在一些问题。 你可以这样使用:
Route::group(['middleware'=>'auth', 'modules'=>'testt'], function() {
Route::resource('/te', 'HomeController');
});