Laravel在路由中传递访问命名路由的变量

时间:2017-07-21 22:07:41

标签: php laravel variables routes

我正在尝试在html链接中传递3个变量值,该链接使用路由来访问使用此代码路由的命名:

<a href="{{ route('gegonota', ['gid' => $gid,'cid' => $cid , 'nid' => $nid]) }}">{{$nomos->name}}</a>

路线功能也是

Route::get('gegonota/{gid?}/{cid?}/{nid?}', ['uses' => 'GegonosController@index', 'as' => 'gegonota']);

但它无法正常工作。 我该怎么做。 感谢

2 个答案:

答案 0 :(得分:0)

你可以试试这个。

Time.time

答案 1 :(得分:0)

只需从您的路线参数中删除?即可:

Route::get('gegonota/{gid}/{cid}/{nid}', [
'uses' => 'GegonosController@index', 
'as' => 'gegonota'
]);

如果您想使用?,则需要提供默认值,请检查docs

如果您使用 Laravel v5.4 ,则需要将路线更改为:

Route::get('gegonota/{gid}/{cid}/{nid}', [
  'uses' => 'GegonosController@index' 
])->name('gegonota');
相关问题