ItSolutionStuff.com

How to Get Current Route Name in Laravel?

By Hardik Savani • April 16, 2024
Laravel

Hello Guys,

In this post, we will learn laravel get current route name. you will learn how to get current route name in laravel. you will learn how to get current url name in laravel. step by step explain laravel get current route. Here, Create a basic example of laravel get route name from url.

You can use this example with laravel 6, laravel 7, laravel 8, laravel 9, laravel 10 and laravel 11 versions.

If you need to get the current route name, you can use either the Request or Route facade. I will give you two examples, one for using the Route facade and another for using the Request facade, so you can get the route name using either method. You can see both examples below.

Using Request:

$routeName = Request::route()->getName();

print($routeName);

Using Route:

$routeName = Route::getCurrentRoute()->getPath();

print($routeName);

I hope it can help you...

Tags: Laravel
Hardik Savani

Hardik Savani

I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.

📺 Subscribe on YouTube

We Are Recommending You

Laravel 10 Resource Route and Controller Example

Read Now →

Laravel Login with Mobile Number OTP Tutorial

Read Now →

Laravel Route Pass Multiple Parameters Example

Read Now →

How to Get All Routes in Laravel?

Read Now →

Laravel Redirect to Route from Controller Example

Read Now →

How to Change From Name in Laravel Mail?

Read Now →

How to Add Two Factor Authentication with SMS in Laravel?

Read Now →

Laravel Send SMS to Mobile with Nexmo Example

Read Now →

How to Send SMS using Twilio in Laravel?

Read Now →

How to Create Custom Route File in Laravel?

Read Now →

Laravel Get Route Parameters in Middleware Example

Read Now →

How to Send Mail using Sendgrid in Laravel?

Read Now →

How to Redirect Route with Querystring in Laravel?

Read Now →

How to Generate Route with Query String in Laravel?

Read Now →