3
I am trying to pass two parameters on the route, however, I get this error:
"Route Pattern "/fiche/{id}/client/{id}" cannot Reference variable name "id" more than Once."
The route used:
Route::get('/visualizar/{ficha_id}/{cliente_id}', 'AnamneseController@visualizar')
->name('visualizar');
Button where the parameter is passed:
<a href="{{route('ficha.visualizar', ['ficha_id' => $f->id, 'cliente_id' => $cliente->id])}}">
Visualizar Ficha
</a>
Am I doing something wrong? What should I fix?
EDIT All application routes
Route::get('/', function () {
return view('welcome');
});
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::group(['as' => 'cadastro.', 'prefix' => 'cadastro'], function () {
Route::get('/listar', 'CadastroController@index')->name('index');
Route::get('/adicionar', 'CadastroController@create')->name('adicionar');
Route::post('/salvar', 'CadastroController@store')->name('salvar');
Route::get('/{id}/visualizar', 'CadastroController@show')->name('visualizar');
Route::get('/{id}/editar', 'CadastroController@edit')->name('editar');
});
Route::group(['as' => 'ficha.', 'prefix' => 'ficha'], function () {
Route::get('/listar', 'AnamneseController@index')->name('index');
Route::get('/cliente/{id}/adicionar', 'AnamneseController@create')->name('adicionar');
Route::get('/{id}/cliente/{id}', 'AnamneseController@edit')->name('editar');
Route::post('/salvar', 'AnamneseController@store')->name('salvar');
Route::get('/visualizar/{ficha_id}/{cliente_id}', 'AnamneseController@visualizar')->name('visualizar');
});
Try to change
ficha_id
forfichaId
and see what happens.– Jéf Bueno
Did you post the right route? The error concerns the route
"/ficha/{id}/cliente/{id}"
and you posted a route'/visualizar/{ficha_id}/{cliente_id}'
.– Andre Gusmao
@LINQ switched and changed nothing...
– Felipe Ramon
@Andregusmao yes, the route is correct. However, no matter what name I put between "
{ }
" remains/ficha/{id}/cliente/{id}
– Felipe Ramon
Got to put all your routes I think you have routes with problems?
– novic
@Virgilionovic edited and inserted all routes.
– Felipe Ramon
Route::get('/{id}/cliente/{id}', 'AnamneseController@edit')->name('editar');
can’t be like that! one of the errors is that it only accepts a variable name per route– novic
Damn life, I was blind wanting to solve the problem of the visualizing route that I didn’t even bother to check the others.. You figured it out here... @Virgilionovic, thanks a lot, man!
– Felipe Ramon