1

这是我的 routes.php 代码

    Route::auth();

    Route::group(['middleware' => 'web'], function () {
Route::group(['namespace' => 'Admin', 'prefix' => 'admin', 'middleware' => ['auth','role:Admin']], function(){

    Route::get('/home', 'HomeController@index');

    Route::get('user/data', ['as' => 'admin.user.data','uses'=>'UserController@userData']);
    Route::resource('user', 'UserController');

    Route::get('merchant/data', ['as' => 'admin.merchant.data','uses'=>'MerchantController@merchantData']);
    Route::resource('merchant', 'MerchantController');

    Route::get('bcategory/data', ['as' => 'admin.bcategory.data','uses'=>'BusinessCategoryController@bcategoyData']);
    Route::resource('bcategory', 'BusinessCategoryController');

    Route::get('ccategory/data', ['as' => 'admin.ccategory.data','uses'=>'CouponCategoryController@ccategoyData']);
    Route::resource('ccategory', 'CouponCategoryController');

    Route::delete('image/{image}', ['as' => 'admin.image.destroy','uses'=>'ImageController@destroy']);

    Route::put('image/{image}/primary', ['as' => 'admin.image.updateprimary','uses'=>'ImageController@setPrimaryImage']);
});

Route::group(['namespace' => 'Merchant', 'prefix' => 'merchant', 'middleware' => 'role:Merchant'], function(){

 });
});

php artisan route 中的路由列表:list

谁能告诉我为什么两次应用网络路由我只添加了一次到组中间件。?

4

2 回答 2

3

进行了更改以始终调用web中间件,RouteServiceProvider因此无需在以后指定它routes.php

更新的文档说:

请记住,web中间件组routes.phpRouteServiceProvider.

于 2016-05-06T10:23:02.060 回答
0

现在“web”中间件组被应用到默认值。Route::group(['middleware' => 'web']从你的文件 route.php 中删除它

于 2016-05-16T16:05:02.640 回答