Get Current URL in Blade

Blade can be confusing sometimes, but once you get to understand it you will realize how powerful and easy to use it can be.

One of the things I've seen asked around a lot is how to get the current URL in Blade and it's really simple. As you've probably got used to already, Laravel has functions for basically everything and it's the case here too.

How to get current URL in Blade

The easiest way to do it is by using the Request facade.


It can be used even in @if or @foreach statements without a problem, just like below:

@if (some condition)
	{{ Request::url() }}

And it can even be used in the @if or @foreach statement:

@if (Request::url() == 'some url')
	// Do something

But this isn't all. You can use all of the Request functions in Blade templates without a problem.