Search code examples
phplaravellaravel-8

How to get Route name in Laravel 8


I am working with a laravel 8 app, I want to get the route name which we write in the ->name() method. Basically want to print this name in title of page.

->name() method in the laravel 8, Laravel Routes

Route::view('/documents_for_approvals','document_approval')->name('Document Approvals'); //SA


Solution

  • In your View :

    {{Route::current()->getName()}}
    

    If you want to show the current route name in the browser Tab foreach pages add this to your layout view

    <title>{{Route::current()->getName()}}</title>