Search code examples
laravellaravel-7

laravel 7 redirect to external url with GET parameters


Is there any elegant way to redirect to an external url with parameters in laravel?

I'm using this code:

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

but would prefer to use something like this (it doesn't work because the route is not defined):

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

Solution

  • You can do something like:

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