使用资源时,资源如users
用作前缀。然后不再需要在组中使用前缀。以下解决了该问题:
Route::name('admin.')->namespace('Admin')->middleware(['auth'])->group(function () {
Route::resource('users', 'UsersController');
});
老的:
| | GET|HEAD | users/users | admin.users.index | App\Http\Controllers\Admin\UsersController@index | web,auth |
| | POST | users/users | admin.users.store | App\Http\Controllers\Admin\UsersController@store | web,auth |
| | GET|HEAD | users/users/create | admin.users.create | App\Http\Controllers\Admin\UsersController@create | web,auth |
| | GET|HEAD | users/users/{user} | admin.users.show | App\Http\Controllers\Admin\UsersController@show | web,auth |
| | PUT|PATCH | users/users/{user} | admin.users.update | App\Http\Controllers\Admin\UsersController@update | web,auth |
| | DELETE | users/users/{user} | admin.users.destroy | App\Http\Controllers\Admin\UsersController@destroy | web,auth |
| | GET|HEAD | users/users/{user}/edit | admin.users.edit | App\Http\Controllers\Admin\UsersController@edit | web,auth |
+--------+-----------+-------------------------+-------------------------------+----------------------------------------------------+--------------+
没有更新的资源:
| | GET|HEAD | users | admin.users.index | App\Http\Controllers\Admin\UsersController@index | web,auth |
| | POST | users | admin.users.store | App\Http\Controllers\Admin\UsersController@store | web,auth |
| | GET|HEAD | users/create | admin.users.create | App\Http\Controllers\Admin\UsersController@create | web,auth |
| | GET|HEAD | users/{user} | admin.users.show | App\Http\Controllers\Admin\UsersController@show | web,auth |
| | PUT|PATCH | users/{user} | admin.users.update | App\Http\Controllers\Admin\UsersController@update | web,auth |
| | DELETE | users/{user} | admin.users.destroy | App\Http\Controllers\Admin\UsersController@destroy | web,auth |
| | GET|HEAD | users/{user}/edit | admin.users.edit | App\Http\Controllers\Admin\UsersController@edit | web,auth |
+--------+-----------+--------------------+-------------------------------+----------------------------------------------------+--------------+