Posted inLaravel / php

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
@endforeach

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

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

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
@endif

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

using the method Request::segment()

// Returns true for domain_name.com/api/article and false for domain_name.com/api/edit
@if (Request::segment(2) == 'article')
	// Here Best Busineess Logic
@endif

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 infinityknow.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.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

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

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype