【问题标题】:Laravel 5.2 named route usage with variable parameterLaravel 5.2 带有可变参数的命名路由用法
【发布时间】:2016-04-06 00:27:56
【问题描述】:

我有这样的路线:

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

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

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

但是这种格式不起作用。

如何在仍然使用命名路由的同时向变量菜单传递值(而不是在href 中硬编码url)?

【问题讨论】:

    标签: php laravel routes laravel-5 laravel-5.2


    【解决方案1】:

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

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

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

    【讨论】:

    猜你喜欢
    • 2018-04-06
    • 2017-04-04
    • 1970-01-01
    • 2016-04-23
    • 2016-10-12
    • 1970-01-01
    • 2013-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多