php – What is the correct way to pass two or more parameters in the route?

Question:

I'm trying to pass two parameters in the route, however I get this error:

"Route pattern "/file/{id}/customer/{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');
});

Answer:

My friend, the error itself says "cannot reference variable name "id" more than once.". You cannot reference the variable name "id" more than once!

Scroll to Top
AllEscort