How to Get Current Route Name in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel 10 Resource Route and Controller Example
- Laravel Login with Mobile Number OTP Tutorial
- Laravel Route Pass Multiple Parameters Example
- How to Get All Routes in Laravel?
- Laravel Redirect to Route from Controller Example
- How to Change From Name in Laravel Mail?
- How to Add Two Factor Authentication with SMS in Laravel?
- Laravel Send SMS to Mobile with Nexmo Example
- How to Send SMS using Twilio in Laravel?
- How to Create Custom Route File in Laravel?
- Laravel Get Route Parameters in Middleware Example
- How to Send Mail using Sendgrid in Laravel?
- How to Redirect Route with Querystring in Laravel?
- How to Generate Route with Query String in Laravel?