Laravel 5.2 named route usage with variable parameter

。_饼干妹妹 提交于 2019-12-23 09:07:25

问题


I have a route like this:

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

In my blade template I use the named route like this:

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

But this format does not work.

How do I pass the variable menu a value while still using the named route (rather than hard coding a url in the href)?


回答1:


You can pass your route parameters as the second argument to route() helper:

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

Make sure you're using correct names. Your routing defines subscription.create route while your template refers to organisations.index route.



来源:https://stackoverflow.com/questions/34556484/laravel-5-2-named-route-usage-with-variable-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!