I am aware that in the previous versions of Laravel (e.g. 4), one could get the current uri through
Route::current()->uri();
However, this doesn't seem to work in Laravel 5.7 or later. I am wondering how it should be rewritten. Please note that I am accessing the uri in a blade view and hence cannot use non-static methods.
You can get current url in laravel using folling methods.
// Get the current URL without the query string...
echo url()->current();
// Get the current URL including the query string...
echo url()->full();
// Get the full URL for the previous request...
echo url()->previous();
Each of these methods may also be accessed via the URL facade:
use Illuminate\Support\Facades\URL;
echo URL::current();
For more information you can read full documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With