Laravel 路由:资源路由命名
利用 names
属性来修改,格式为 动作 => 名词
,例如 'index' => 'photos.index',
为 PhotosController
里的方法 index
,对应路由命名 'photos.index'
。完整例子如下:
Route::resource('photos', 'PhotosController', ['names' => [
'index' => 'photos.index',
'create' => 'photos.create',
'store' => 'photos.store',
'show' => 'photos.show',
'edit' => 'photos.edit',
'update' => 'photos.update',
'destroy' => 'photos.destroy'
]]);
推荐文章: