How to Get Current Route Name in Laravel

Laravel get current route name, route Path; Through this tutorial, we will learn how to get current route name on blade view and controller file in laravel apps.

Laravel Get Current Route Name, Route Path

Use the below given solution to get current route name on blade view and controller file in laravel apps; is as follows:

  • To Get Current Route Name On Controller
  • To Get Current Route Name On Blade View

To Get Current Route Name On Controller

If we want to get the route name, route path on controller file in laravel apps; So, we can use the following method to get route name and route path on controller file; as follows:

First, include the Route facade to your controller:

use Illuminate\Support\Facades\Route;

then use the following code into controller file:

    public function yourMethodHere(){
        $routeName = Route::currentRouteName();
	dd($routeName);
    }

To Get Current Route Name On Blade View

If we want to get the route name, route path on blade view file in laravel apps; So, we can use the following method to get route name and route path on blade view file; as follows:

use the Route facade directly in your Blade view:

{{ Route::currentRouteName() }}

Recommended Laravel Tutorials

Recommended:-Laravel Try Catch

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *