Level 20
This could be a solution ? (optional parameter)
Route::get('asset/{theme_id}/{key}/{page?}', ['as' => 'asset.view', 'uses' => 'AssetController@view']);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a view file that is listing all the sections as a list
<li>
<a href="{{route('asset.view',array('theme_id'=>$asset->theme_id,'key'=>"$asset->key"))}}">{{$asset->key}}</a>
</li>
in my route file, I created a route to the view function like this
Route::get('asset/{theme_id}/{key}', ['as' => 'asset.view', 'uses' => 'AssetController@view']);
laravel's default URI format is asset/view/{theme_id}/{key} and my problem is the second parameter key having an extra /. so the final URI become asset/view/1254125/section/page and it returns a 404 page.
how can I fix this?
This could be a solution ? (optional parameter)
Route::get('asset/{theme_id}/{key}/{page?}', ['as' => 'asset.view', 'uses' => 'AssetController@view']);
Please or to participate in this conversation.