Reputation: 105
How can I name my Route::resource
so I can call it later in Laravel 5.5?
This works
Route::get('newclientTAB', 'NewClientControllerTAB@index')->name('newclientTAB');
This doesn't
Route::resource('articles','ArticleController')->name('articles');
Upvotes: 2
Views: 2628
Reputation: 111829
If you use:
Route::resource('articles','ArticleController')
Laravel will automatically set names for you routes.
You can run:
php artisan route:list
to see them.
The will have names:
However if you want to use custom name prefix you can set it like this:
Route::resource('articles','ArticleController', ['names' => 'xyz'])
and then your routes will have names xyz.index
, xyz.store
and so on
If you want to go further you can also set individual names for example:
Route::resource('articles','ArticleController', ['names' => ['create' => 'foo','update' => 'bar']])
so you can set names only for some routes so you will get foo
, bar
and articles.index
, articles.show
and so on
Upvotes: 6