Sometimes we need to check the current URL of requests in our application. Either we need to check the complete path or a specific string of current URL. It can be done easily using following methods provided with Laravel request object: Inspecting The Request Path / Route

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' => 'address']); so these are the ways to check and work on current URL in Laravel.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners