How to Get Current Route Name?

Today, We want to share with you PHP Laravel 5.8 Get Current Route Name?.In this post we will show you laravel get route name in middleware, hear for laravel get current route parameters we will give you demo and example for implement.In this post, we will learn about laravel check if route name exists with an example.

How to Get Current Route Name?

There are the Following The simple About Laravel PHP Get Current Route Name? Full Information With Example and source code.

Read Also:  Best Online College and Universities Degree Ranking

As I will cover this Post with live Working example to develop laravel get route name in view, so the laravel 5.8 get route name structures for this example is following below.

Example 1 : Laravel Get Current Route Name

Fetch Current Route Name Path in Laravel 5.8

		Route::getCurrentRoute()->getPath();
		
		//or
		
		\Request::route()->getName();

Example 2 :get current route name in Laravel 5.8

You can use in template:

		<?php $path = Route::getCurrentRoute()->getPath(); ?>
		<?php if (starts_with($path, 'admin/')) echo "active"; ?>

Example 3 : PHP Laravel 5.7 current route name path and action in laravel

Laravel All Bout Route

		$route = Route::current();
		$name = Route::currentRouteName();
		$action = Route::currentRouteAction();

Example 4

Laravel 5.5 Get Route Name in Controller, View and Middleware

Read Also:  Laravel Get Route Parameters in middleware Example

Get Route Name using Request:

		public function myProduct()
		{
			$get_routeName = Request::route()->getName());
			dd($get_routeName);
		}

Example 5

Get Route Name using Route:

		public function myProduct()
		{
			$get_routeName = Route::currentRouteName();
			dd($get_routeName);
		}

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Get Current Route Name using Laravel.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  PHP Delete All Directory Files In Directory

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Search Filter using Nodejs and MySQL
  2. Read Also:  File Upload - Auto Resize Compress-Reduce image using PHP
  3. Read Also:  Get Current Route Name using Laravel Example
  4. Read Also:  jQuery CDN Link Cheat Sheet Download
  5. Read Also:  how to delete (splice) an element from nested JSON using Vuejs
  6. Read Also:  JQuery Set Focus on First TextBox
  7. Read Also:  Object Expressions using Angular Example
  8. Read Also:  BOOTSTRAP ACCORDION WITH PLUS MINUS ICON
  9. Read Also:  Laravel Send Mailgun Mail using PHP cURL
  10. Read Also:  JQuery Set Focus on First TextBox