I am working on a legacy code, a project built with Laravel 5.2, and I am getting an error:
Route pattern "/api/v0/taxonomy/{term}/{{term}}" cannot reference variable name "term" more than once.
For this route:
/post/106
This is are my routes:
Route::group(['prefix' => 'api'], function() {
Route::group(['prefix' => 'v0'], function () {
Route::get('route/{a?}/{b?}/{c?}/{d?}', 'DynamicRouteController@resolve');
Route::get('id/{id}', 'DynamicRouteController@resolveId');
Route::get('search', 'SearchController@search');
Route::resource('taxonomy/{term}','TaxonomyController');
});
});
Not sure, why am I getting this error?
When you define a route as a resource then Laravel seems to create all the routes necessary for your resource: GET, POST, PATCH, DELETE.
So you would just need to define Route::resource('taxonomy','TaxonomyController');
or Route::resource('taxonomy.post','TaxonomyPostController');
Check docs
You just need rename your route parameter like this:
Route::resource('taxonomy/{term}','TaxonomyController', ['parameters'
=> ['{term}' => 'your_name']]);
be careful!!!!. you need insert bracket. this will cause wrong result:
Route::resource('taxonomy/{term}','TaxonomyController', ['parameters'
=> ['term' => 'your_name']] );
attention: 'your_name' should not be same as your parameter so this method make wrong result.
Route::resource('taxonomy/{term}','TaxonomyController', ['parameters'
=> ['{term}' => 'term']});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With