Laravel How to redirect to a URL with query parameters?

Laravel helpers: the redirect() function returns a redirect HTTP response, or returns the redirector instance if called with no arguments:

Ish Sookun

1 min read

While writing this method I needed it to return to the profile page of a user after successfully creating that user account. I don't know if I am doing it the correct way but one obvious way I thought is to return the browser a URL with the query parameter that uniquely identifies the user and pass in the new user's identity.

Then, in the voluminous documentation of Laravel 9, I tried to find how to do it. So far, the best options are:

$url = "https://example.com?key={$value}";

return redirect($link);

Using a named route:

return redirect()->route('route_name',['key'=> $value]);