whi*_*hoa 5 php laravel laravel-5
我正在使用搜索过滤器的get参数,并且需要能够更改查询字符串变量的值并返回修改后的url(作为字符串变量,没有任何花哨,没有重定向或任何东西).这就是我到目前为止所发生的事情:
public function index(Request $request){
echo $request->fullUrl();
// outputs https://test.com/search?type=somestring
$request->merge(['type' => 'anotherstring']);
echo $request->fullUrl();
// still outputs https://test.com/search?type=somestring
// is there a way to change a parameter value in the url and
// return the modified url string?
}
Run Code Online (Sandbox Code Playgroud)
我认为如果情况变得更糟,我会手动解析字符串,但感觉就像有一种"laravel方式"来解决这个问题我碰巧丢失了?
小智 14
请fullUrlWithQuery
改用.
echo $request->fullUrlWithQuery(['type' => 'anotherstring']);
Run Code Online (Sandbox Code Playgroud)