Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Developer654079525's avatar

Getting the current named route(s)

How to check the if the current route name is one of two predefined route names? Currently I have:

<a class={{ Route::is('blog') ? ' active' : '' }}{{ Route::is('blogdetail') ? ' active' : '' }}" href=#>MyLink</a>

Perhaps, there is some better routine/way of checking the current named route from a list of predefined routes?

0 likes
4 replies
Snapey's avatar
Snapey
Best Answer
Level 122

You can change the name blogdetail to blog.detail and blog to blog.index then use blog.* in your is() functiom

2 likes
Snapey's avatar

You can also pass many patterns into the is() function

<a class={{ Route::is('blog', 'blogdetail') ? ' active' : '' }}" href=#>MyLink</a>

My preference is to name routes with some hierarchy

1 like

Please or to participate in this conversation.