imperium2335
imperium2335

Reputation: 24122

Laravel 5 custom named routes in resource controllers

How can I pass in my own extra named routes for a resource controller?

I have:

Route::resource('logistics', 'LogisticsController', ['names' => [
    'index-inbound' => 'logistics.indexInbound'
]]);

But this does not work.

Upvotes: 0

Views: 136

Answers (1)

lukasgeiter
lukasgeiter

Reputation: 153030

You can't really add additional routes to a resource route. However, you can add any other routes you want and point them to the same controller:

Route::get('logistics/inbound', ['name' => 'logistics.index-inbound', 'uses' => 'LogistictsController@indexInbound']);
Route::resource('logistics', 'LogisticsController');

Just make sure that you register your custom routes before the resource route as otherwise they might get overridden.

Upvotes: 1

Related Questions