简体   繁体   English

使用URI段而不是查询字符串生成Laravel URL

[英]Generate Laravel URL using URI segments instead of query string

I'm using the following code to generate a link: 我正在使用以下代码来生成链接:

{{ URL::route('monthly',array($year,$month_number)) }}

Which looks like 看起来像

/monthly?1999&5 /每月?1999&5

But what I really need is: 但是我真正需要的是:

/monthly/1999/5 / monthly / 1999/5

How should I accomplish this? 我应该如何做到这一点?

You have to create a route to support those parameters: 您必须创建一条路由来支持这些参数:

Route::get('montly/{year}/{month_number}', 'ControllerName@show');

And your controller method: 和您的控制器方法:

public function show($year, $month_number)
{
    ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM