Laravel 5.2使用可变参数命名路由使用

The*_*apa 7 php routes laravel laravel-5 laravel-5.2

我有这样的路线:

// Open New Subscription page
Route::get('/account/subscriptions/create/{menu}', ['uses' => 'Subscriptions\SubscriptionController@create', 'as' => 'subscription.create']);
Run Code Online (Sandbox Code Playgroud)

在我的刀片模板中,我使用这样的命名路由:

<a href="{!! route('organisations.index') . "/p11-c3" !!}">
Run Code Online (Sandbox Code Playgroud)

但这种格式不起作用.

如何传递变量菜单中的值,而仍使用已命名的路线(而不是硬编码urlhref)?

jed*_*ylo 17

您可以将路由参数作为route()帮助器的第二个参数传递:

<a href="{!! route('organisations.index', ['menu' => 'p11-c3']) !!}">
Run Code Online (Sandbox Code Playgroud)

确保使用正确的名称.您的路由定义了subscription.create路由,而模板引用了organisations.index路由.