This is untested, but after looking on the documentation for resource controllers it seems as though you can manually set their names. I'm assuming Laravel automatically namespaces grouped resource controller routes to avoid name collision, but you can override this to avoid going back through the rest of your app (just beware of future name collision):
Route::resource(
'books',
'BooksController',
array(
'names' => array(
'index' => 'photo.index',
'create' => 'photo.create',
'store' => 'photo.store',
'show' => 'photo.show',
'edit' => 'photo.edit',
'update' => 'photo.update',
'destroy' => 'photo.destroy',
)
)
);
Shorter Method:
Just define a quick method at the top of your routes.php
file to shorten up this repetitive task of creating an array of route names. Still not the greatest solution, but I believe its the only thing you can do with how Laravel has this set up.
function createRouteNames($resource) {
$names = array();
$types = ['index', 'create', 'store', 'show', 'edit', 'update', 'destroy'];
foreach($types as $type) {
$names[$type] = $resource . '.' . $type;
}
return $names;
}
Route::resource('books', 'BooksController', ['names' => createRouteNames('books')]);
Note: [] === array()
and may not be supported on older PHP's, meaning you may need to replace them with the old syntax.