Today, We want to share with you Get Current Url Parameter using Laravel.In this post we will show you laravel get url parameters in middleware, hear for get value of URL parameters into Controller (Laravel) we will give you demo and example for implement.In this post, we will learn about Laravel Request getting current path with query string with an example.
Get Current Url Parameter using Laravel
There are the Following The simple About Get Current Url Parameter using Laravel Full Information With Example and source code.
As I will cover this Post with live Working example to develop Laravel 5.7 get current url with parameters, so the laravel get url parameters in view for this example is following below.
Get Current URL with Parameters:
using Request Facade
$GetcurrentURL = \Request::fullUrl(); dd($GetcurrentURL);
Get Current URL without Parameters:
using URL Facade
$GetcurrentURL = \URL::current(); dd($GetcurrentURL); //OR Second Way $GetcurrentURL = \Request::url(); dd($GetcurrentURL);
Get Only Parameters:
using $request Object
//www.myLivedomainname.com/post/list?page=2 $parameters = \Request::segment(3); dd($parameters);
Laravel – get current URL in controller or view?
$GetcurrentURL = URL::current(); dd($GetcurrentURL);
Laravel Get Current URL in a Blade View
Get the current path
@if (Request::path() == '/product-title') // your condition Source Code @endif
Compare the current URL to a pattern
@if (Request::is('product/*')) // your condition Source Code @endif
Get only a segment of the current URL
// Returns true for yourdomainname.com/product/post and false for yourdomainname.com/product/edit @if (Request::segment(2) == 'post') // your condition Source Code @endif
Get the URL without query string
@if (Request::url() == 'some string') // your condition Source Code @endforeach
Get the full URL, including query string
@if (str_contains(Request::fullUrl(), 'product-list')) // your condition Source Code @endif
I hope you get an idea about Get Current Url Parameter using Laravel.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.
Here are some more FAQ related to this Article: