【发布时间】:2018-07-23 07:19:45
【问题描述】:
laravel 命名路由它生成我不想要的查询字符串。
来自文档:
LARAVEL 5.6
如果我在 LARAVEL 中访问命名路由会生成带有查询字符串的 URL 将参数传递给 route() 助手的第二个参数 不想要。我希望通过 URL 参数。
我的代码:
Route::get('/posts/count', 'PostController@index');
route(posts.index, [count => 3]) // /posts?3
// i don't want this but i get it
route(posts.index, [count => 3]) // /posts/3
// i want this but i don't get it
【问题讨论】:
-
你能详细说明一下吗??
-
您实际上需要有一个参数,需要在 URI 中替换任何其他内容作为查询参数添加
-
你使用
resource作为Route::resource(/posts', 'PostController');吗? -
你这里没有
named route
标签: string laravel parameters named-routing