How to get current URL with parameters in Laravel 5

How to get current URL with parameters in Laravel 5

In this post we will give you information about How to get current URL with parameters in Laravel 5. Hear we will give you detail about How to get current URL with parameters in Laravel 5And how to use it also give you demo for it if it is necessary.

In this post, I will tell you how can you get base url, current url with query string and url segment in Laravel.

While working with Laravel, i need many times to get current url and its segment, you can get current url by using helper function URL::current().


How to get current URL without query string in Laravel

  1. returnURL::current();
  2. OR
  3. returnRequest::url();
  return URL::current();
           OR
  return Request::url();


How to get current URL with query string in Laravel

  1. returnRequest::fullUrl();
return Request::fullUrl();



How to get url parameters in Laravel

You can easily get your url segment in Laravel by using segment method. Let’s assume i have a url with some query string.

www.domain.tld/user/list?page=2

  1. $url_segment=Request::segment(3);
 $url_segment = Request::segment(3);

Now you can easily get your current url by using above methods whenever you need.

Hope this code and post will helped you for implement How to get current URL with parameters in Laravel 5. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

5  +  2  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US