Frage

I am running into this issue where if I define a param in that first route, the second throws this error:

"Route pattern "/browse/{brand}/{{brand}}" cannot reference variable name "brand" more than once."

Route::resource('browse/{brand}', 'BrowseController');

Route::group(array('prefix' => 'service'), function() { 
    Route::resource('authenticate', 'AuthenticationController');
});

If I take out the param, of course that breaks the browse route, but then the auth route works.

Does anyone know the reason for this?

War es hilfreich?

Lösung

The reason is because Route::resource creates several (RESTful) route handlers for you in the background for the controller you specify:

http://laravel.com/docs/controllers#resource-controllers

Take a look at the table called: Actions Handled By Resource Controller

You can see that Laravel will already handle routes for you that take parameter that you can use to implement browsing.

I don't think that the intended usage for Route::resource is to be parametrized like you are trying to.

Of course you can always implement additional routes if those do not match your needs.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top