laravel 7 使用 GET 参数重定向到外部 url

laravel 7 redirect to external url with GET parameters

有什么优雅的方法可以重定向到带有 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,
    ...
]));

$url

中定义要重定向的 url

那就用

return Redirect::away($url);

这是一个简单的例子

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

Docs

您可以这样做:

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