Laravel:(如何)是否可以使用参数链接到命名路由?

Pim*_*Pim 5 php laravel laravel-5

我定义了以下路线:

Route::get('/tours/{country_identifier}', ['as' => 'country', 'uses' => 'CountryController@index']);
Run Code Online (Sandbox Code Playgroud)

现在我想使用类似的东西链接到这个命名路线

route('country')
Run Code Online (Sandbox Code Playgroud)

填写 {country_identifier} 参数,例如“/tours/Canada”。

我怎样才能做到这一点?

sha*_*ddy 5

您可以将参数作为第二个参数数组传递:

route('country', ['country_identifier' => $someValue]);
Run Code Online (Sandbox Code Playgroud)

你可以看一下文档,里面有很多有用的例子:)