How to get current,full and previous URL in laravel Blade?

Laravel

Nicesnippets

118

30-04-2020


Hello Friends,

Laravel provide helper and facade for getting current URL,full URL and previous URL. in laravel project many time required previous url for back button. if you have to print dynamic domain then use url()->current().

// Get the current URL without the query string...

echo url()->current();

// output : http://localhost:8000

// Get the current URL including the query string...

echo url()->full();

// output : http://localhost:8000?type=1

// Get the full URL for the previous request...

echo url()->previous();

// output : http://localhost:8000?type=1

I hope it can help you...