我如何命名我的Route::resource
,以便稍后在Laravel 5.5中调用它?
这适用于Route::get('newclientTAB', 'NewClientControllerTAB@index')->name('newclientTAB');
这不是Route::resource('articles','ArticleController')->name('articles');
如果您使用:
Route::resource('articles','ArticleController')
Laravel将自动为您的路线设置名称。
你可以运行:
php artisan route:list
去看他们。
将有名字:
但是,如果要使用自定义名称前缀,可以像下面这样设置:
Route::resource('articles','ArticleController', ['names' => 'xyz'])
然后你的路线将有xyz.index
,xyz.store
等名称
如果你想更进一步,你也可以设置个别名称,例如:
Route::resource('articles','ArticleController', ['names' => ['create' => 'foo','update' => 'bar']])
所以你只能为某些路线设置名称,这样你就可以获得foo
,bar
和articles.index
,articles.show
等等