Laravel - Requests - Retrieving The Request Url
To retrieve the full URL for the incoming request you may use the url
or fullUrl
methods. The url
method will return the URL without the query string, while the fullUrl
method includes the query string:
$url = $request->url();
$urlWithQueryString = $request->fullUrl();
If you would like to append query string data to the current URL, you may call the fullUrlWithQuery
method. This method merges the given array of query string variables with the current query string:
$request->fullUrlWithQuery(['type' => 'phone']);