Sometimes while working on the project, we generally need to get current route with parameters and we do invest a lot of time to get current route in laravel. So here, i will give you some examples or code to get laravel current route with parameter.
Here you will get the answer of some questions which are as listed below.
1) How to get current URL without query string in Laravel
2) How to get current URL with query string in Laravel
3) How to get url parameters in Laravel
So, Let’s see the answer of these questions one by one.
Q1: How to get current URL without query string in Laravel
Answer: For getting current url without query string, we can use URL::current() or Request::url() method like below.
return \URL::current(); OR return \Request::url();
Q2: How to get current URL with query string in Laravel
Answer: We can get current url with query string or full url with domain name and all query string using the laravel method given below.
Q3: How to get url parameters in Laravel
Answer: You can get only parameters from a url which may have parameter or query string usong the laravel method mentioned below.
Example Url: http://www.phpzone.in/post?type=laravel&status=1
$url_segment = \Request::segment(3);
You can also know how to clear laravel cache by clicking on the link below