How to Get Current Route Name in Laravel

In this tutorial, you can learn, how to get the current route name using laravel. There are a few ways to get the route name in the controller, middleware, or blade file. So, let's start:


Get route name in Controller or Middleware

1. You can get the route name using the route facade in controller or middleware

use Illuminate\Support\Facades\Route;

public function index(){
        $routeName = Route::currentRouteName();


2. Using request facade to get the current route name

public function index(){
        $routeName = \Request::route()->getName();


Get route name in Blade View

Simiarly, you can also use in blade file to get current route

{ Route::currentRouteName() }}
Tags : laravel PHP

Related Post

How to Add Country List in Laravel App?
How to Get current date, week, month, year wise data in Laravel
How to protect pdf generated from laravel MPDF
How to connect Dynamic database in Laravel