Get Current URL in Laravel

  Dec 2023
  ITSolutionsGuides
  Category: Laravel
Get Current URL in Laravel

Hi Developers,

Lets see how to Get Current URL in Laravel. While developing laravel applications sometimes we need to get the current url of the page for some validations purposes or some of the functions need to be performed from the specific url.

To retrieve the current URL in Laravel, use url()->current() method. This returns the URL without query parameters, enabling precise URL handling in your applications.

Let's Start Coding

current() with Helper

$currentURL = url()->current();
  
dd($currentURL);

Let's Start Coding

full() with Helper(with query string parameters)

$currentURL = url()->full();
    
dd($currentURL);

Let's Start Coding

Lets get the current URL by using the current() facade in laravel ,
current() with Facade

$currentURL = URL::current();
    
dd($currentURL);

Let's Start Coding

Lets get the current URL by using the full() Facades in laravel ,

full() with Facade(with query string parameters)

$currentURL = URL::full();
    
dd($currentURL);

Let's Start Coding

Lets get the current URL by using the request in laravel ,
using Request

$currentURL = Request::url();
  
dd($currentURL);

Let's Start Coding

Lets see how to get the Previous URL in Laravel

$url = url()->previous();
  
dd($url);

Let's Start Coding

Lets see how to get the Current Route in Laravel

$route = Route::current()->getName();
  
dd($route);

We hope it helps everyone. Thanks for supporting ITSolutionsGuides and keep supporting us also follow us in social media platforms.

Subscribe for NewsLetter

Be the first to know about releases and tutorial news and solutions.

We care about your data in our privacy policy.

ITSolutionsGuides

ITSolutionsGuides was started mainly to provide good and quality web solutions for all the developers. We provide tutorials to support all the developers and also we try to provide solutions to the errors we face while coding.

Contact US

ITSolutionsGuides, provide users with an easy-to-use form to reach out for support or inquiries.

whatsapp  gmail  instagram-new--v1  facebook-circled  twitter-circled  linkedin  github  pinterest 

Copyright © 2023 - 2024 All rights reserved | ITSolutionsGuides