如何在Laravel中处理多个GET请求

问题描述 投票:0回答:1

我正在Laravel开发一家网上商店,我想按类别,标签和价格范围过滤产品。当我单击:

<a href="{{ route('shop.show', ['category' => 'testCategory'])}}">Test Category </a>

它应该将我重定向到:shop?category=testCategory,没关系。

并且当我单击<a href="{{ route('shop.show', ['tag' => 'testTag'])}}">Test Tag </a>它将我重定向到:shop?tag=testTag这就是问题所在,一种产品只有一个类别,但可能有多个标签或多个标签,并且价格在特定价格范围之间所以,我想要的是:

当用户位于:shop?category=testCategory并单击<a href="{{ route('shop.show', ['tag' => 'testTag'])}}">Test Tag </a>他应该重定向到:shop?category=testCategory&tag=testTag 不发送 shop?tag=testTag并放置类别过滤器

我希望我能很好地解释这一点。

php laravel get
1个回答
0
投票

您可以像这样向路由添加多个查询参数:

<a href="{{ route('shop.show', ['category' => 'testCategegory', 'tag' => 'testTag'])}}">Test Tag </a>

这是否回答了您的问题?

© www.soinside.com 2019 - 2024. All rights reserved.