How to Get Current Route Name in Laravel?
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 and laravel 10 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.
$routeName = Request::route()->getName();
$routeName = Route::getCurrentRoute()->getPath();
I hope it can help you...
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?