看这个例子:
Route::group(array('prefix' => 'admin'), function()
{
//this resolves to admin/departments
Route::resource('departments', 'DepartmentsAdminController');
//this resolves to admin/users
Route::resource('users', 'UsersAdminController');
//this resolves to admin/companies
Route::resource('companies', 'CompaniesAdminController');
Route::resource('projects', 'ProjectsAdminController');
Route::resource('jobs', 'JobsAdminController');
Route::resource('milestones', 'MilestonesAdminController');
Route::resource('hours', 'HoursAdminController');
Route::resource('notes', 'NotesAdminController');
Route::resource('briefs', 'BriefsAdminController');
Route::resource('brief_items', 'BriefItemsAdminController');
});
Laravel 根据前缀更改路由名称,在这种情况下前缀是admin
所以现在所有以 admin 为前缀的路由名称参见:
admin.users.create
admin.users.edit
但是,如果我想将前缀更改为其他内容,我将不得不更改整个应用程序中的路由名称。
我想要的是保持路线名称不变
users.create
users.edit
并更改前缀而不更改路由名称。
有没有办法让资源控制器中的路由名称保持静态并随时更改前缀?