Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top