中间件除外

时间:2016-12-15 18:41:16

标签: laravel

我有一组我应用auth中间件的路线。

除了tournaments.show ????

我该怎么办?

我只找到了带有$ this->中间件语法的示例,但没有找到带有Route :: group

的示例
Route::group(['middleware' => ['auth']],
function () {
  Route::resource('tournaments', 'TournamentController', [
    'names' => [
      'index' => 'tournaments.index',
      'show' => 'tournaments.show',
      'create' => 'tournaments.create',
      'edit' => 'tournaments.edit',                                                       'store' => 'tournaments.store',                                                     'update' => 'tournaments.update'                                                  ],
  ]);
});

1 个答案:

答案 0 :(得分:2)

您可以show resource()路由Route::group(['middleware' => ['auth']], function () { Route::resource('tournaments', 'TournamentController', [ 'names' => ['index' => 'tournaments.index', 'create' => 'tournaments.create', 'edit' => 'tournaments.edit', 'store' => 'tournaments.store', 'update' => 'tournaments.update' ], 'except' => ['show'], ] ); });

Route::get('tournaments/{id}', 'TournamentController@show')->name('tournaments.show');

然后在组外定义:

break