Laravel get current URL path – How to get Current url path?

Laravel get current URL path Using Request::url(), Request::fullUrl(), Request::path(), Request::segment() and {{ Request::is(‘article/*’) }} Examples.

Laravel get current URL path

Get the current URL without the query string. The methods we can use for this are Request::url() , Request::fullUrl() , Request::path() , Request::is() and Request::segment() .

using the Request::url() method

@if (Request::url() == 'some string')
	// Here Best Busineess Logic

using the Request::fullUrl()
Get the current fullUrl

@if (str_contains(Request::fullUrl(), 'some-string'))
	// Here Best Busineess Logic

Get Current URL in a Blade View

How to get current URL or path in Blade?

@if (Request::path() == '/article-title')
	// Here Best Busineess Logic

Don’t Miss : Get Current URL In A Blade View Using Laravel

using the method Request::segment()

// Returns true for and false for
@if (Request::segment(2) == 'article')
	// Here Best Busineess Logic

Laravel – Get Current URL in a Blade View Example

Get only a segment of the current URL using the method

Segment: {{ Request::segment(1) }}

//Results Segment: article

Get current URL to Compare the a pattern

Is: {{ Request::is('article/*') }}

I hope you get an idea about Laravel get current URL path.
I would like to have feedback on my 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.

Leave a Comment