laravel 7 重定向到带有 GET 参数的外部 URL



有什么优雅的方法可以重定向到带有 laravel 参数的外部 url?

我正在使用以下代码:

$redirect = redirect(config('app.paypal.url') .'?'. http_build_query([
'charset'       => 'utf-8',
'paymentaction' => 'sale',
'no_note'       => 1,
...
]));

但更愿意使用这样的东西(它不起作用,因为未定义路由(:

$redirect = redirect(route(config('app.paypal.url'), [
'charset'       => 'utf-8',
'paymentaction' => 'sale',
'no_note'       => 1,
...
]));

你可以执行以下操作:

return redirect()->away('https://my.url.com')->with('user',$user)
->with('pass_code',$pass_code)
->with('amount',$amount)
->with('hash_value',$hash_value);

定义要在$url中重定向的网址

然后只需使用

return Redirect::away($url);

这是一个简单的例子

return Redirect::away('http://www.google.com?q=lorem+ipsum');

文档